misc cleanup
[rpi-open-firmware.git] / arm_chainloader / drivers / sdhost_impl.cc
index f5da771..ecc7b7d 100644 (file)
@@ -134,24 +134,21 @@ struct BCM2708SDHost : BlockDevice {
        }\r
 \r
        void configure_pinmux() {\r
+               logf("configuring pinmux ...\n");\r
+\r
                GP_FSEL4 = 0x24000000;\r
                GP_FSEL5 = 0x924;\r
 \r
-               logf("waiting for pinmux pull update ...\n");\r
-\r
                GP_PUD = 2;\r
                mfence();\r
                udelay(500);\r
                GP_PUD = 0;\r
 \r
-               logf("waiting for pinmux clock update ...\n");\r
-\r
-               /* are these in bank 1 or 2? ah who gives a fuck ... */\r
+               /* are these in bank 1 or 2? */\r
                GP_PUDCLK1 = GP_PUDCLK1_PUDCLKn32_SET;\r
                GP_PUDCLK2 = GP_PUDCLK2_PUDCLKn64_SET;\r
                udelay(500);\r
 \r
-               logf("ok ...\n");\r
                GP_PUDCLK1 = 0;\r
                GP_PUDCLK2 = 0;\r
 \r
@@ -200,8 +197,6 @@ struct BCM2708SDHost : BlockDevice {
 \r
                get_response();\r
 \r
-               //printf("Cmd: 0x%x Resp: %08x %08x %08x %08x\n", current_cmd, r[0], r[1], r[2], r[3]);\r
-\r
                if (SH_CMD & SH_CMD_FAIL_FLAG_SET) {\r
                        if (SH_HSTS & SDHSTS_ERROR_MASK) {\r
                                logf("ERROR: sdhost status: 0x%x\n", SH_HSTS);\r
@@ -246,11 +241,6 @@ struct BCM2708SDHost : BlockDevice {
 \r
                logf("SD card has arrived!\n", r);\r
 \r
-               is_high_capacity = (r[0] & MMC_OCR_HCS) == MMC_OCR_HCS;\r
-\r
-               if (is_high_capacity)\r
-                       logf("This is an SDHC card!\n");\r
-\r
                return true;\r
 \r
        }\r
@@ -275,8 +265,6 @@ struct BCM2708SDHost : BlockDevice {
                        return false;\r
                rca = SD_R6_RCA(r);\r
 \r
-               logf("RCA = 0x%x\n", rca);\r
-\r
                send_136_resp(MMC_SEND_CID, MMC_ARG_RCA(rca));\r
                if (!wait_and_get_response())\r
                        return false;\r
@@ -293,15 +281,13 @@ struct BCM2708SDHost : BlockDevice {
                return true;\r
        }\r
 \r
-//#define DUMP_READ\r
-\r
        bool wait_for_fifo_data(uint32_t timeout = 100000) {\r
                uint32_t t = timeout;\r
 \r
                while ((SH_HSTS & SH_HSTS_DATA_FLAG_SET) == 0) {\r
                        if (t == 0) {\r
                                putchar('\n');\r
-                               logf("ERROR: no FIFO data, timed out after %dus!\n", timeout)\r
+                               logf("ERROR: no FIFO data, timed out after %dus!\n", timeout);\r
                                return false;\r
                        }\r
                        t--;\r
@@ -312,8 +298,6 @@ struct BCM2708SDHost : BlockDevice {
        }\r
 \r
        void drain_fifo() {\r
-               /* fuck me with a rake ... gently */\r
-\r
                wait();\r
 \r
                while (SH_HSTS & SH_HSTS_DATA_FLAG_SET) {\r
@@ -361,9 +345,8 @@ struct BCM2708SDHost : BlockDevice {
                /* drain useful data from FIFO */\r
                for (i = 0; i < 128; i++) {\r
                        /* wait for FIFO */\r
-                       if (!wait_for_fifo_data()) {\r
+                       if (!wait_for_fifo_data())\r
                                break;\r
-                       }\r
 \r
                        uint32_t hsts_err = SH_HSTS & SDHSTS_ERROR_MASK;\r
                        if (hsts_err) {\r
@@ -405,10 +388,7 @@ struct BCM2708SDHost : BlockDevice {
        bool select_card() {\r
                send(MMC_SELECT_CARD, MMC_ARG_RCA(rca));\r
 \r
-               if (!wait())\r
-                       return false;\r
-\r
-               return true;\r
+               return wait();\r
        }\r
 \r
        bool init_card() {\r
@@ -500,12 +480,6 @@ struct BCM2708SDHost : BlockDevice {
        void restart_controller() {\r
                is_sdhc = false;\r
 \r
-               logf("hcfg 0x%X, cdiv 0x%X, edm 0x%X, hsts 0x%X\n",\r
-                    SH_HCFG,\r
-                    SH_CDIV,\r
-                    SH_EDM,\r
-                    SH_HSTS);\r
-\r
                logf("Restarting the eMMC controller ...\n");\r
 \r
                configure_pinmux();\r
@@ -521,14 +495,10 @@ struct BCM2708SDHost : BlockDevice {
                if (init_card()) {\r
                        card_ready = true;\r
 \r
-                       /*\r
-                        * looks like a silicon bug to me or a quirk of csd2, who knows\r
-                        */\r
-                       for (int i = 0; i < 3; i++) {\r
-                               if (!read_block(0, nullptr)) {\r
+                       /* work around quirk / silicon bug */\r
+                       for (int i = 0; i < 3; i++)\r
+                               if (!read_block(0, nullptr))\r
                                        panic("fifo flush cycle %d failed", i);\r
-                               }\r
-                       }\r
                } else {\r
                        panic("failed to reinitialize the eMMC controller");\r
                }\r
@@ -577,4 +547,4 @@ BCM2708SDHost STATIC_DRIVER g_SDHostDriver {};
 \r
 BlockDevice* get_sdhost_device() {\r
        return &g_SDHostDriver;\r
-}
\ No newline at end of file
+}\r
This page took 0.034027 seconds and 4 git commands to generate.