mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* boot init code depending on i2c eeprom value
@ 2012-08-03  8:06 christian.buettner
  2012-08-03 12:20 ` Marc Reilly
  2012-08-03 13:21 ` Sascha Hauer
  0 siblings, 2 replies; 4+ messages in thread
From: christian.buettner @ 2012-08-03  8:06 UTC (permalink / raw)
  To: barebox


[-- Attachment #1.1: Type: text/plain, Size: 1287 bytes --]

Hi all,

i need to set the pin-mux of the board init code depending on an ID coming 
from 
an i2C EEPROM of the board.
Is it possible to do something like this:


...

//Using the e.g. the postcore_initcall phase to init i2C
static int
ecuv6_postcore_init(void)
{
        //Set I2C EEPROM (24C32R) PIN MUX
        mxc_iomux_v3_setup_multiple_pads(i2c_eeprom_pads, 
ARRAY_SIZE(i2c_eeprom_pads));
        imx53_add_i2c2(NULL);
        return 0;
}
postcore_initcall(ecuv6_postcore_init);

//In the console_initcall phase, i2C should be probed to read ID
static int
ecuv6_console_init(void)
{
        imx53_init_lowlevel(0);
        ecuv6_set_system_serial();
 
        //get_bb_pcb_number reads data from 
        char bb_ID;
        bb_ID = get_i2c_ID();

        //Set Pinmux depending on i2C result
        if(bb_ID = 0xAB) {
                mxc_iomux_v3_setup_multiple_pads(AB_pads, ARRAY_SIZE(
AB_pads));
        }
        else if(bb_ID = 0xCD) {
                mxc_iomux_v3_setup_multiple_pads(CD_pads, ARRAY_SIZE(
CD_pads));
        }
 
        imx53_add_uart0();

        return 0;
}
console_initcall(ecuv6_console_init);

...


Actually this is not working. The i2c_imx:i2c_imx_probe(..) function gets 
called later.
Is there a way or concept to do something like this?

christian

[-- Attachment #1.2: Type: text/html, Size: 4500 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: boot init code depending on i2c eeprom value
  2012-08-03  8:06 boot init code depending on i2c eeprom value christian.buettner
@ 2012-08-03 12:20 ` Marc Reilly
  2012-08-03 13:21 ` Sascha Hauer
  1 sibling, 0 replies; 4+ messages in thread
From: Marc Reilly @ 2012-08-03 12:20 UTC (permalink / raw)
  To: christian.buettner, barebox

Hi,

>i need to set the pin-mux of the board init code depending on an ID coming
from 
>an i2C EEPROM of the board. 
>Is it possible to do something like this: 

>postcore_initcall(ecuv6_postcore_init); 
> console_initcall(ecuv6_console_init); 
>Actually this is not working. The i2c_imx:i2c_imx_probe(..) function gets
called later. 
>Is there a way or concept to do something like this? 

Do it (all) in a device_initcall() function?

Cheers,
Marc




_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: boot init code depending on i2c eeprom value
  2012-08-03  8:06 boot init code depending on i2c eeprom value christian.buettner
  2012-08-03 12:20 ` Marc Reilly
@ 2012-08-03 13:21 ` Sascha Hauer
  2012-08-07 13:54   ` Antwort: " christian.buettner
  1 sibling, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2012-08-03 13:21 UTC (permalink / raw)
  To: christian.buettner; +Cc: barebox

On Fri, Aug 03, 2012 at 10:06:28AM +0200, christian.buettner@rafi.de wrote:
> Hi all,
> 
> i need to set the pin-mux of the board init code depending on an ID coming 
> from 
> an i2C EEPROM of the board.
> Is it possible to do something like this:
> 
> 
> ...
> 
> //Using the e.g. the postcore_initcall phase to init i2C
> static int
> ecuv6_postcore_init(void)
> {
>         //Set I2C EEPROM (24C32R) PIN MUX
>         mxc_iomux_v3_setup_multiple_pads(i2c_eeprom_pads, 
> ARRAY_SIZE(i2c_eeprom_pads));
>         imx53_add_i2c2(NULL);
>         return 0;
> }
> postcore_initcall(ecuv6_postcore_init);
> 
> //In the console_initcall phase, i2C should be probed to read ID
> static int
> ecuv6_console_init(void)
> {
>         imx53_init_lowlevel(0);
>         ecuv6_set_system_serial();
>  
>         //get_bb_pcb_number reads data from 
>         char bb_ID;
>         bb_ID = get_i2c_ID();
> 
>         //Set Pinmux depending on i2C result
>         if(bb_ID = 0xAB) {
>                 mxc_iomux_v3_setup_multiple_pads(AB_pads, ARRAY_SIZE(
> AB_pads));
>         }
>         else if(bb_ID = 0xCD) {
>                 mxc_iomux_v3_setup_multiple_pads(CD_pads, ARRAY_SIZE(
> CD_pads));
>         }
>  
>         imx53_add_uart0();
> 
>         return 0;
> }
> console_initcall(ecuv6_console_init);
> 
> ...
> 
> 
> Actually this is not working. The i2c_imx:i2c_imx_probe(..) function gets 
> called later.
> Is there a way or concept to do something like this?

You must call get_i2c_ID after registering the i2c device. you can call
mxc_iomux_v3_setup_multiple_pads multiple times, i.e. once for the UART
pins in console_init and once later when you know what hardware you
have.
This of cause does not work when your console pins depend on the
hardware version, in this case you must register your console in a
device_initcall later.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Antwort: Re: boot init code depending on i2c eeprom value
  2012-08-03 13:21 ` Sascha Hauer
@ 2012-08-07 13:54   ` christian.buettner
  0 siblings, 0 replies; 4+ messages in thread
From: christian.buettner @ 2012-08-07 13:54 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox


[-- Attachment #1.1: Type: text/plain, Size: 2389 bytes --]

Thanks..

it worked! 



Von:    Sascha Hauer <s.hauer@pengutronix.de>
An:     christian.buettner@rafi.de, 
Kopie:  barebox@lists.infradead.org
Datum:  03.08.2012 15:21
Betreff:        Re: boot init code depending on i2c eeprom value



On Fri, Aug 03, 2012 at 10:06:28AM +0200, christian.buettner@rafi.de 
wrote:
> Hi all,
> 
> i need to set the pin-mux of the board init code depending on an ID 
coming 
> from 
> an i2C EEPROM of the board.
> Is it possible to do something like this:
> 
> 
> ...
> 
> //Using the e.g. the postcore_initcall phase to init i2C
> static int
> ecuv6_postcore_init(void)
> {
>         //Set I2C EEPROM (24C32R) PIN MUX
>         mxc_iomux_v3_setup_multiple_pads(i2c_eeprom_pads, 
> ARRAY_SIZE(i2c_eeprom_pads));
>         imx53_add_i2c2(NULL);
>         return 0;
> }
> postcore_initcall(ecuv6_postcore_init);
> 
> //In the console_initcall phase, i2C should be probed to read ID
> static int
> ecuv6_console_init(void)
> {
>         imx53_init_lowlevel(0);
>         ecuv6_set_system_serial();
> 
>         //get_bb_pcb_number reads data from 
>         char bb_ID;
>         bb_ID = get_i2c_ID();
> 
>         //Set Pinmux depending on i2C result
>         if(bb_ID = 0xAB) {
>                 mxc_iomux_v3_setup_multiple_pads(AB_pads, ARRAY_SIZE(
> AB_pads));
>         }
>         else if(bb_ID = 0xCD) {
>                 mxc_iomux_v3_setup_multiple_pads(CD_pads, ARRAY_SIZE(
> CD_pads));
>         }
> 
>         imx53_add_uart0();
> 
>         return 0;
> }
> console_initcall(ecuv6_console_init);
> 
> ...
> 
> 
> Actually this is not working. The i2c_imx:i2c_imx_probe(..) function 
gets 
> called later.
> Is there a way or concept to do something like this?

You must call get_i2c_ID after registering the i2c device. you can call
mxc_iomux_v3_setup_multiple_pads multiple times, i.e. once for the UART
pins in console_init and once later when you know what hardware you
have.
This of cause does not work when your console pins depend on the
hardware version, in this case you must register your console in a
device_initcall later.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


[-- Attachment #1.2: Type: text/html, Size: 4321 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-08-07 13:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-03  8:06 boot init code depending on i2c eeprom value christian.buettner
2012-08-03 12:20 ` Marc Reilly
2012-08-03 13:21 ` Sascha Hauer
2012-08-07 13:54   ` Antwort: " christian.buettner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox