On 05/22/2016 01:35 PM, Wills Wang wrote: > > > On 05/22/2016 07:13 PM, Marek Vasut wrote: >> On 05/22/2016 05:59 AM, Wills Wang wrote: >>> Use function "ddr_init" for ath79 platform DDR initialization, >>> and put it into mach/ddr.h >>> >>> Signed-off-by: Wills Wang <wills.w...@live.com> >>> --- >>> >>> arch/mips/mach-ath79/ar933x/ddr.c | 2 +- >>> arch/mips/mach-ath79/ar934x/ddr.c | 2 +- >>> arch/mips/mach-ath79/include/mach/ath79.h | 1 - >>> arch/mips/mach-ath79/include/mach/ddr.h | 2 +- >>> arch/mips/mach-ath79/qca953x/ddr.c | 2 +- >>> board/qca/ap121/ap121.c | 2 +- >>> board/qca/ap143/ap143.c | 2 +- >>> board/tplink/wdr4300/wdr4300.c | 2 +- >>> 8 files changed, 7 insertions(+), 8 deletions(-) >>> >>> diff --git a/arch/mips/mach-ath79/ar933x/ddr.c >>> b/arch/mips/mach-ath79/ar933x/ddr.c >>> index 84e1cfa..b5940cb 100644 >>> --- a/arch/mips/mach-ath79/ar933x/ddr.c >>> +++ b/arch/mips/mach-ath79/ar933x/ddr.c >>> @@ -103,7 +103,7 @@ DECLARE_GLOBAL_DATA_PTR; >>> #define DDR_TAP_VAL0 0x08 >>> #define DDR_TAP_VAL1 0x09 >>> -void ddr_init(void) >>> +void ddr_init(const u16 cpu_mhz, const u16 ddr_mhz, const u16 bus_mhz) >> Call it ar933x_ddr_init() here >> >>> { >>> void __iomem *regs; >>> u32 val; >>> diff --git a/arch/mips/mach-ath79/ar934x/ddr.c >>> b/arch/mips/mach-ath79/ar934x/ddr.c >>> index 2ebb89b..c467fb2 100644 >>> --- a/arch/mips/mach-ath79/ar934x/ddr.c >>> +++ b/arch/mips/mach-ath79/ar934x/ddr.c >>> @@ -35,7 +35,7 @@ static const struct ar934x_mem_config >>> ar934x_mem_config[] = { >>> [AR934X_DDR2] = { 0xc7d48cd0, 0x9dd0e6a8, 0x33, 0, 0x10012 }, >>> }; >>> -void ar934x_ddr_init(const u16 cpu_mhz, const u16 ddr_mhz, const >>> u16 ahb_mhz) >>> +void ddr_init(const u16 cpu_mhz, const u16 ddr_mhz, const u16 bus_mhz) >> Keep this one. If you want to have ddr_init() as a universal function, >> that's fine. But consider the situation where you want to have a single >> u-boot binary for multiple ar9xxx . In that case, you would need all of >> those different ar9xxx_ddr_init() functions and you'd need some >> universal function (ath79_ddr_init() ?) which would in turn call the >> right ar9xxx_ddr_init() . > You mean like this: > > void ath79_ddr_init(const u16 cpu_mhz, const u16 ddr_mhz, const u16 > bus_mhz) > { > > if (soc_is_ar933x()) > ar933x_ddr_init(cpu_mhz, ddr_mhz, bus_mhz); > else if (soc_is_ar934x()) > ar934x_ddr_init(cpu_mhz, ddr_mhz, bus_mhz); > ...
Yes, very much like that. soc_is_foo() might need tweaking so the compiled would be able to optimize out unavailable branches (in case support for that family is not available). [...] -- Best regards, Marek Vasut _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot