Commit beadff1731bf607eee36467a3d3c12102a178c45
Committed by
Stefan Roese
1 parent
9a04527840
Exists in
v2017.01-smarct4x
and in
30 other branches
mvebu: axp: refactor board_sat_r_get() and caller
Instead of calling board_sat_r_get() only for those boards providing the satr11 value via I2C, call it for all boards and return static values for those not using I2C. In addition to that, make this a weak function to allow for board code to override it. Signed-off-by: Phil Sutter <phil@nwl.cc> Acked-by: Stefan Roese <sr@denx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
Showing 1 changed file with 15 additions and 31 deletions Side-by-side Diff
arch/arm/mach-mvebu/serdes/axp/high_speed_env_lib.c
... | ... | @@ -75,16 +75,24 @@ |
75 | 75 | #endif |
76 | 76 | } |
77 | 77 | |
78 | -static u8 board_sat_r_get(u8 dev_num, u8 reg) | |
78 | +__weak u8 board_sat_r_get(u8 dev_num, u8 reg) | |
79 | 79 | { |
80 | 80 | u8 data; |
81 | 81 | u8 *dev; |
82 | 82 | u32 board_id = board_id_get(); |
83 | 83 | int ret; |
84 | 84 | |
85 | - i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); | |
86 | - | |
87 | 85 | switch (board_id) { |
86 | + case DB_78X60_AMC_ID: | |
87 | + case DB_78X60_PCAC_REV2_ID: | |
88 | + case RD_78460_CUSTOMER_ID: | |
89 | + case RD_78460_SERVER_ID: | |
90 | + case RD_78460_SERVER_REV2_ID: | |
91 | + case DB_78X60_PCAC_ID: | |
92 | + return (0x1 << 1) | 1; | |
93 | + case FPGA_88F78XX0_ID: | |
94 | + case RD_78460_NAS_ID: | |
95 | + return (0x0 << 1) | 1; | |
88 | 96 | case DB_784MP_GP_ID: |
89 | 97 | dev = rd78460gp_twsi_dev; |
90 | 98 | |
91 | 99 | |
... | ... | @@ -94,15 +102,12 @@ |
94 | 102 | dev = db88f78xx0rev2_twsi_dev; |
95 | 103 | break; |
96 | 104 | |
97 | - case DB_78X60_PCAC_ID: | |
98 | - case FPGA_88F78XX0_ID: | |
99 | - case DB_78X60_PCAC_REV2_ID: | |
100 | - case RD_78460_SERVER_REV2_ID: | |
101 | 105 | default: |
102 | 106 | return 0; |
103 | 107 | } |
104 | 108 | |
105 | 109 | /* Read MPP module ID */ |
110 | + i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); | |
106 | 111 | ret = i2c_read(dev[dev_num], 0, 1, (u8 *)&data, 1); |
107 | 112 | if (ret) |
108 | 113 | return MV_ERROR; |
... | ... | @@ -240,7 +245,6 @@ |
240 | 245 | u8 device_rev; |
241 | 246 | u32 rx_high_imp_mode; |
242 | 247 | u16 ctrl_mode; |
243 | - u32 board_id = board_id_get(); | |
244 | 248 | u32 pex_if; |
245 | 249 | u32 pex_if_num; |
246 | 250 | |
... | ... | @@ -251,29 +255,9 @@ |
251 | 255 | if (max_serdes_lines == 0) |
252 | 256 | return MV_OK; |
253 | 257 | |
254 | - switch (board_id) { | |
255 | - case DB_78X60_AMC_ID: | |
256 | - case DB_78X60_PCAC_REV2_ID: | |
257 | - case RD_78460_CUSTOMER_ID: | |
258 | - case RD_78460_SERVER_ID: | |
259 | - case RD_78460_SERVER_REV2_ID: | |
260 | - case DB_78X60_PCAC_ID: | |
261 | - satr11 = (0x1 << 1) | 1; | |
262 | - break; | |
263 | - case FPGA_88F78XX0_ID: | |
264 | - case RD_78460_NAS_ID: | |
265 | - satr11 = (0x0 << 1) | 1; | |
266 | - break; | |
267 | - case DB_88F78XX0_BP_REV2_ID: | |
268 | - case DB_784MP_GP_ID: | |
269 | - case DB_88F78XX0_BP_ID: | |
270 | - satr11 = board_sat_r_get(1, 1); | |
271 | - if ((u8) MV_ERROR == (u8) satr11) | |
272 | - return MV_ERROR; | |
273 | - break; | |
274 | - default: | |
275 | - satr11 = 0; | |
276 | - } | |
258 | + satr11 = board_sat_r_get(1, 1); | |
259 | + if ((u8) MV_ERROR == (u8) satr11) | |
260 | + return MV_ERROR; | |
277 | 261 | |
278 | 262 | board_modules_scan(); |
279 | 263 | memset(addr, 0, sizeof(addr)); |