Cleaning up debug print function.
authorGerd Zellweger <mail@gerdzellweger.com>
Fri, 28 Jun 2013 12:06:43 +0000 (14:06 +0200)
committerGerd Zellweger <mail@gerdzellweger.com>
Tue, 16 Jul 2013 12:55:00 +0000 (14:55 +0200)
devices/ti_twl6030.dev
usr/drivers/omap44xx/mmchs/cm2.c
usr/drivers/omap44xx/mmchs/ctrlmod.c
usr/drivers/omap44xx/mmchs/i2c.c
usr/drivers/omap44xx/mmchs/mmchs.c
usr/drivers/omap44xx/mmchs/twl6030.c

index 9dfa056..a67ca44 100644 (file)
@@ -114,6 +114,14 @@ device ti_twl6030 msbfirst (addr b) "TI TWL6030 Power Companion (via I2C)" {
         vsel 5 type(vsel) "Voltage to apply";
     };
 
+    register mmcctrl id1(0xEE) "MMCCTRL" {
+        _               4 rsvd;
+        vmmc_auto_off   1 "Is the regulator turned off automatically in case card is extracted?";
+        sw_fc           1 "Configure the external receptable mechanical contact";
+        _               1 rsvd;
+        sts_mmc         1 "Is card present?";
+    };
+
     // VMMC registers
     // Table 152
     //register vmmc_cfg_grp addr(b, 0x98) "VMMC Group Configuration" type(cfg_grp);
index 0d8a14a..fb417b3 100644 (file)
@@ -80,6 +80,9 @@ void cm2_enable_i2c(size_t i2c_index)
 {
     assert (i2c_index < 4);
 
+    //omap44xx_l4per_prm_pm_l4per_pwrstctrl_prf(cm2_buf, 1024-1, &l4per_prm);
+    //printf("%s\n", cm2_buf);
+
     omap44xx_l4per_cm2_cm_l4per_i2c_clkctrl_modulemode_wrf(&l4per_cm2, i2c_index, 0x2);
 
     // wait for module to get into functional state
@@ -110,14 +113,13 @@ int cm2_get_hsmmc1_base_clock(void)
  */
 void cm2_debug_print(void)
 {
-    char buf[1024];
-    omap44xx_l3init_cm2_pr(buf, 1024-1, &l3init_cm2);
+    omap44xx_l3init_cm2_pr(cm2_buf, 1024-1, &l3init_cm2);
     printf("%s\n", cm2_buf);
 
-    omap44xx_ckgen_cm2_pr(buf, 1024-1, &clkgen_cm2);
+    omap44xx_ckgen_cm2_pr(cm2_buf, 1024-1, &clkgen_cm2);
     printf("%s\n", cm2_buf);
 
-    omap44xx_l4per_cm2_pr(buf, 1024-1, &l4per_cm2);
+    omap44xx_l4per_cm2_pr(cm2_buf, 1024-1, &l4per_cm2);
     printf("%s\n", cm2_buf);
 }
 
index f86d600..22546f5 100644 (file)
@@ -97,7 +97,7 @@ void sdmmc1_enable_power(void)
 
     // Step 5: wait for SDMMC1_VDDS voltage to stabilize TODO
     // might already be stable after reset? -SG
-    ti_twl6030_vmmc_pr();
+    //ti_twl6030_vmmc_pr();
 
     // Step 6: Disable PWRDNZ mode for MMC1_PBIAS and MMC1 I/O cell
     printk(LOG_NOTE, "%s: Step 6\n", __FUNCTION__);
@@ -112,6 +112,7 @@ void sdmmc1_enable_power(void)
             omap44xx_ctrlmod_PBIASLITE_MMC1_PBIASLITE_VMODE_ERROR_rdf(&ctrlmod));
 
     // Wait for Interrupt
+    printk(LOG_NOTE, "Waiting for pbias Interrupt (id=%d)\n", PBIAS_IRQ);
     while(!pbias_got_irq) { }
 
     printk(LOG_NOTE, "%s: Step 8\n", __FUNCTION__);
index 6719038..d56673c 100644 (file)
@@ -127,20 +127,19 @@ static inline bool ti_i2c_poll_stat(ti_i2c_t *dev, ti_i2c_irqstatus_t flags,
     uint32_t start_ticks = tsc_read();
     uint32_t ticks;
     int32_t waittime = timeout;
-    printk(LOG_NOTE, "waittime = %"PRIu32"\n", waittime);
+    printk(LOG_DEBUG, "waittime = %"PRIu32"\n", waittime);
 
     while (waittime > 0) {
         ti_i2c_irqstatus_t stat = ti_i2c_stat_rd(dev);
-        printk(LOG_NOTE, "stat = 0x%"PRIx16"\n", stat);
+        printk(LOG_DEBUG, "stat = 0x%"PRIx16"\n", stat);
         //ti_i2c_stat_pr(prbuf, PBS-1, dev);
         //printf("%s\n", prbuf);
 
         if (stat & ti_i2c_irq_flag_aas) {
             // address recognized as slave interrupt
             if (stat & ti_i2c_irq_flag_rrdy) {
-                printk(LOG_NOTE, "AAS && RRDY\n");
-                printk(LOG_NOTE, "data = 0x%"PRIx8"\n",
-                        ti_i2c_data_data_rdf(dev));
+                printk(LOG_DEBUG, "AAS && RRDY\n");
+                printk(LOG_DEBUG, "data = 0x%"PRIx8"\n", ti_i2c_data_data_rdf(dev));
                 ti_i2c_stat_aas_wrf(dev, 1);
                 ti_i2c_stat_rrdy_wrf(dev, 1);
             }
@@ -153,7 +152,7 @@ static inline bool ti_i2c_poll_stat(ti_i2c_t *dev, ti_i2c_irqstatus_t flags,
         }
         ticks = tsc_read();
         waittime -= (ticks - start_ticks);
-        printk(LOG_NOTE, "waittime = %"PRIu32"\n", waittime);
+        printk(LOG_DEBUG, "waittime = %"PRIu32"\n", waittime);
         start_ticks = ticks;
     }
     return false;
@@ -173,7 +172,7 @@ static bool ti_i2c_wait_for_free_bus(ti_i2c_t *dev, int32_t timeout)
 static errval_t
 ti_i2c_read(ti_i2c_t *dev, uint8_t *buf, uint16_t length)
 {
-    printk(LOG_NOTE, "ti_i2c_read\n");
+    printk(LOG_DEBUG, "ti_i2c_read\n");
     bool wfb;
     wfb = ti_i2c_wait_for_free_bus(dev, DEFAULT_TIMEOUT);
     if (!wfb) {
@@ -209,7 +208,7 @@ ti_i2c_read(ti_i2c_t *dev, uint8_t *buf, uint16_t length)
     // reading loop
     while (true) {
         // poll for NACK, AL, ARDY, RDR and RRDY
-        printk(LOG_NOTE, "waiting for 0x%"PRIx16"\n", events);
+        printk(LOG_DEBUG, "waiting for 0x%"PRIx16"\n", events);
         while(!ti_i2c_poll_stat(dev, events, &retevents, DEFAULT_TIMEOUT)) {
             // poll for receive ready
         }
@@ -229,7 +228,7 @@ ti_i2c_read(ti_i2c_t *dev, uint8_t *buf, uint16_t length)
         // check if we have finished
         if (retevents & ti_i2c_irq_flag_ardy) {
             // register access ready --> transaction complete
-            printk(LOG_NOTE, "ARDY transaction complete\n");
+            printk(LOG_DEBUG, "ARDY transaction complete\n");
             ti_i2c_stat_ardy_wrf(dev, 1);
             err = SYS_ERR_OK;
             break;
@@ -238,14 +237,14 @@ ti_i2c_read(ti_i2c_t *dev, uint8_t *buf, uint16_t length)
         // read some data
         if (retevents & ti_i2c_irq_flag_rdr) {
             // Receive draining interrupt --> we got the last data bytes
-            printk(LOG_NOTE, "Receive draining interrupt\n");
+            printk(LOG_DEBUG, "Receive draining interrupt\n");
 
             /* get the number of bytes in the FIFO */
             amount = ti_i2c_bufstat_rxstat_rdf(dev);
         }
         else if (retevents & ti_i2c_irq_flag_rrdy) {
             // Receive data ready interrupt --> got data
-            printk(LOG_NOTE, "Receive data ready interrupt\n");
+            printk(LOG_DEBUG, "Receive data ready interrupt\n");
 
             // get the number of bytes in the FIFO
             amount = ti_i2c_bufstat_rxstat_rdf(dev);
@@ -277,18 +276,18 @@ ti_i2c_write(ti_i2c_t *dev, uint8_t *buf, uint16_t length)
     uint16_t amount = 0, sofar = 0;
     errval_t err = SYS_ERR_OK;
 
-    printk(LOG_NOTE, "ti_i2c_write(dev, *buf=%"PRIu8", length=%"PRIu16")\n", *buf, length);
+    printk(LOG_DEBUG, "ti_i2c_write(dev, *buf=%"PRIu8", length=%"PRIu16")\n", *buf, length);
     bool wfb;
     wfb = ti_i2c_wait_for_free_bus(dev, DEFAULT_TIMEOUT);
     if (!wfb) {
         printk(LOG_ERR, "wait for bus free timed out\n");
         return SYS_ERR_I2C_WAIT_FOR_BUS;
     }
-    printk(LOG_NOTE, "bus is free, proceeding\n");
+    printk(LOG_DEBUG, "bus is free, proceeding\n");
 
     // TODO: interrupt-driven?
 
-    //printk(LOG_NOTE, "AFTER WAIT FOR BUS:\n");
+    //printk(LOG_DEBUG, "AFTER WAIT FOR BUS:\n");
     //ti_i2c_stat_pr(prbuf, PBS-1, dev);
     //printf("%s\n", prbuf);
 
@@ -298,7 +297,7 @@ ti_i2c_write(ti_i2c_t *dev, uint8_t *buf, uint16_t length)
     ti_i2c_cnt_wr(dev, length);
     ti_i2c_sa_sa_wrf(dev, 0x48);
 
-    //printk(LOG_NOTE, "AFTER WRITE SETUP:\n");
+    //printk(LOG_DEBUG, "AFTER WRITE SETUP:\n");
     //ti_i2c_stat_pr(prbuf, PBS-1, dev);
     //printf("%s\n", prbuf);
     // Force write of 1st bit ez
@@ -326,7 +325,7 @@ ti_i2c_write(ti_i2c_t *dev, uint8_t *buf, uint16_t length)
     // writing loop
     while (true) {
         // poll for NACK, AL, ARDY, XDR and XRDY
-        printk(LOG_NOTE, "waiting for 0x%"PRIx16"\n", events);
+        printk(LOG_DEBUG, "waiting for 0x%"PRIx16"\n", events);
         while(!ti_i2c_poll_stat(dev, events, &retevents, DEFAULT_TIMEOUT)) {
             // poll for events
         }
@@ -347,7 +346,7 @@ ti_i2c_write(ti_i2c_t *dev, uint8_t *buf, uint16_t length)
         if (retevents & ti_i2c_irq_flag_ardy) {
             // register access ready --> transaction complete
             ti_i2c_stat_ardy_wrf(dev, 1);
-            printk(LOG_NOTE, "ARDY transaction complete\n");
+            printk(LOG_DEBUG, "ARDY transaction complete\n");
             err = SYS_ERR_OK;
             break;
         }
@@ -355,15 +354,15 @@ ti_i2c_write(ti_i2c_t *dev, uint8_t *buf, uint16_t length)
         // send some data
         if (retevents & ti_i2c_irq_flag_xdr) {
             // transmit draining interrupt --> we are sending the last data bytes
-            printk(LOG_NOTE, "Receive draining interrupt\n");
+            printk(LOG_DEBUG, "Receive draining interrupt\n");
 
             /* get the number of bytes that fit in the FIFO */
             amount = ti_i2c_bufstat_txstat_rdf(dev);
-            printk(LOG_NOTE, "#bytes = %"PRIu16"\n", amount);
+            printk(LOG_DEBUG, "#bytes = %"PRIu16"\n", amount);
         }
         else if (retevents & ti_i2c_irq_flag_xrdy) {
             // transmit data ready interrupt --> can send data
-            printk(LOG_NOTE, "Receive data ready interrupt\n");
+            printk(LOG_DEBUG, "Receive data ready interrupt\n");
 
             // get the number of bytes that fit in the FIFO
             amount = ti_i2c_bufstat_txstat_rdf(dev);
@@ -377,7 +376,7 @@ ti_i2c_write(ti_i2c_t *dev, uint8_t *buf, uint16_t length)
         }
 
         // write the bytes to the fifo
-        printk(LOG_NOTE, "writing %"PRIu16" bytes\n", amount);
+        printk(LOG_DEBUG, "writing %"PRIu16" bytes\n", amount);
         for (int i = 0; i < amount; i++) {
             ti_i2c_data_data_wrf(dev, buf[sofar++]);
         }
@@ -404,7 +403,7 @@ ti_i2c_write(ti_i2c_t *dev, uint8_t *buf, uint16_t length)
  */
 errval_t ti_i2c_transfer(int devid, struct i2c_msg *msgs, size_t msgcount)
 {
-    printk(LOG_NOTE, "ti_i2c_transfer\n");
+    printk(LOG_DEBUG, "ti_i2c_transfer\n");
     if (!i2c_initialized[devid]) {
         return SYS_ERR_I2C_UNINITIALIZED;
     }
index 9671c3c..815f9bd 100644 (file)
@@ -637,28 +637,28 @@ static void mmchs_detect_card(void)
     sdhc_ise_wr(&sdhc, ise);
 
     printf("Waiting for card to be inserted .. \n");
-    sdhc_pr(PRBUFL, &sdhc);
-    printf("%s\n", PRBUF);
+    //sdhc_pr(PRBUFL, &sdhc);
+    //printf("%s\n", PRBUF);
 
-    sdhc_ise_pr(PRBUFL, &sdhc);
-    printf("%s\n", PRBUF);
-    sdhc_ie_pr(PRBUFL, &sdhc);
-    printf("%s\n", PRBUF);
+    //sdhc_ise_pr(PRBUFL, &sdhc);
+    //printf("%s\n", PRBUF);
+    //sdhc_ie_pr(PRBUFL, &sdhc);
+    //printf("%s\n", PRBUF);
 
-    /* int i = 0; */
-    /* while (sdhc_ps_cins_rdf(&sdhc)!=0x1) { */
+     int i = 0;
+     while (sdhc_ps_cins_rdf(&sdhc)!=0x1) {
 
-    /*     if (++i>10000) { */
-    /*         printf("No card detected .. \n"); */
-    /*         return; */
-    /*     } */
+         if (++i>10000) {
+             printf("No card detected .. \n");
+             return;
+         }
 
-    /*     mmchs_wait_msec(1); */
-    /* } */
+         mmchs_wait_msec(1);
+     }
 
-    /* printf("Card detected .. \n"); */
-    /* /\* mmchs_init_stream(); *\/ */
-    /* /\* mmchs_identify_card(); *\/ */
+     printf("Card detected .. \n");
+      mmchs_init_stream();
+     mmchs_identify_card();
 }
 
 /*
index 1f8f573..8aff0a7 100644 (file)
@@ -196,15 +196,21 @@ errval_t ti_twl6030_set_vmmc_vsel(int millis)
 
     ti_twl6030_vsel_t vsel = millis_to_vsel(millis);
 
+    //ti_twl6030_mmcctrl_vmmc_auto_off_wrf(&twl, 0x0);
     // set regulator to application mode
     ti_twl6030_vmmc_cfg_grp_grp_app_wrf(&twl, 0x1);
+    
     // turn on
-    ti_twl6030_cfg_state_w_t st = ti_twl6030_cfg_state_w_default;
-    st = ti_twl6030_cfg_state_w_grp_app_insert(st, 0x1);
-    st = ti_twl6030_cfg_state_w_state_insert(st, ti_twl6030_pwr_on);
-    ti_twl6030_vmmc_cfg_state_r_rawwr(&twl, st);
+    //ti_twl6030_cfg_state_w_t st = ti_twl6030_cfg_state_w_default;
+    //st = ti_twl6030_cfg_state_w_grp_app_insert(st, 0x1);
+    //st = ti_twl6030_cfg_state_w_grp_con_insert(st, 0x1);
+    //st = ti_twl6030_cfg_state_w_grp_mod_insert(st, 0x1);
+    //st = ti_twl6030_cfg_state_w_state_insert(st, ti_twl6030_pwr_on);
+    //ti_twl6030_vmmc_cfg_state_w_wr(&twl, st);
 
     ti_twl6030_vmmc_cfg_voltage_vsel_wrf(&twl, vsel);
 
+    ti_twl6030_vmmc_pr();
+
     return SYS_ERR_OK;
 }