Hi, I found some bugs for the gpio setup for ppc405ep and was about to fix them. After i fixed them (for 405ep) I realised that it's rather impossible to have a function like gpio_set_chip_configuration to setup the gpios for all ppc4xx, without turning it into ifdef hell. Even worse you can't even have one which only takes care of the ppc440ep. Maybe I misunderstood the datasheet of the ppc440ep, so please correct me if I'm wrong. According to Table 29-6 on page 687 which lists the registers for the alternate1 function the tsrl bits for gpio 12 have to be 01, but for gpio 13 they have to be 00. Both are inputs and both are alt1, so I don't see how to find a rule to decide what value has to be set. It's no big deal to have such a function for the ppc405ep and some others, but it should be obvious to see for what processors this function was tested and should fail with #error else.
The Bugs I've found: 1. The addresses of the select registers (input/output/3state), which are defined in gpio.h of the ppc405ep are wrong. The address of the low register is 4 bytes higher than the high register. Furthermore GPIOs 0-16 are managed by the high register. Because the meaning and the address of the registers have changed, gpios 0-16 can be configured, which makes spotting this bug more difficult. 2. config_gpio assumes the address of the high register to be 4 bytes above the low register, which isn't the case for 405ep. 3. gpio_set_chip_configuration also assumes the address of the high register to be 4 bytes above the low register. 3.1 Furthermore the 3state select registers will get set, which should always be 00 for the 405ep. 3.2 The TCR register bits will only get set for gpio_out && gpio_sel, but they must be set for all outputs on 405ep. 4. The taihu board (405ep) uses gpio_set_chip_configuration. This bugs probably could have been avoided if the addresses of the registers would have been defined with #else #error, at least we would have a scapegoat now, who defined the wrong addresses. So why not add this rule to the coding style? Because no 405ep board uses config_gpio and only taihu uses gpio_set_chip_configuration, I think it would be best to undef this error prone functions and registers for 405ep. The registers defined in ppc405.h are correct, so most boards are o.k. anyway. I would have a patch for the registers and config_gpio, so if you don't agree with my solution I can submit it. Regards Markus ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users