Commit 09227dd9df9b033be0a92bb5fa4319b22a9e6ba7

Authored by Yao Yuan
Committed by York Sun
1 parent 036f3f3379

ls1021atwr: add hwconfig setting to do pin mux

Freescale LS1021ATWR share some pins. Hwconfig option is used to
allows users to choose the pin functions.

Signed-off-by: Yuan Yao <yao.yuan@freescale.com>
[York Sun: revised commit message]
Reviewed-by: York Sun <yorksun@freescale.com>

Showing 1 changed file with 78 additions and 0 deletions Side-by-side Diff

board/freescale/ls1021atwr/ls1021atwr.c
... ... @@ -13,6 +13,7 @@
13 13 #include <asm/arch/fsl_serdes.h>
14 14 #include <asm/arch/ls102xa_stream_id.h>
15 15 #include <asm/pcie_layerscape.h>
  16 +#include <hwconfig.h>
16 17 #include <mmc.h>
17 18 #include <fsl_esdhc.h>
18 19 #include <fsl_ifc.h>
... ... @@ -54,6 +55,17 @@
54 55 #define KEEP_STATUS 0x0
55 56 #define NEED_RESET 0x1
56 57  
  58 +#define SOFT_MUX_ON_I2C3_IFC 0x2
  59 +#define SOFT_MUX_ON_CAN3_USB2 0x8
  60 +#define SOFT_MUX_ON_QE_LCD 0x10
  61 +
  62 +#define PIN_I2C3_IFC_MUX_I2C3 0x0
  63 +#define PIN_I2C3_IFC_MUX_IFC 0x1
  64 +#define PIN_CAN3_USB2_MUX_USB2 0x0
  65 +#define PIN_CAN3_USB2_MUX_CAN3 0x1
  66 +#define PIN_QE_LCD_MUX_LCD 0x0
  67 +#define PIN_QE_LCD_MUX_QE 0x1
  68 +
57 69 struct cpld_data {
58 70 u8 cpld_ver; /* cpld revision */
59 71 u8 cpld_ver_sub; /* cpld sub revision */
... ... @@ -271,6 +283,68 @@
271 283 }
272 284 #endif
273 285  
  286 +#ifndef CONFIG_QSPI_BOOT
  287 +int config_board_mux(void)
  288 +{
  289 + struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE);
  290 + int conflict_flag;
  291 +
  292 + conflict_flag = 0;
  293 + if (hwconfig("i2c3")) {
  294 + conflict_flag++;
  295 + cpld_data->soft_mux_on |= SOFT_MUX_ON_I2C3_IFC;
  296 + cpld_data->i2c3_ifc_mux = PIN_I2C3_IFC_MUX_I2C3;
  297 + }
  298 +
  299 + if (hwconfig("ifc")) {
  300 + conflict_flag++;
  301 + /* some signals can not enable simultaneous*/
  302 + if (conflict_flag > 1)
  303 + goto conflict;
  304 + cpld_data->soft_mux_on |= SOFT_MUX_ON_I2C3_IFC;
  305 + cpld_data->i2c3_ifc_mux = PIN_I2C3_IFC_MUX_IFC;
  306 + }
  307 +
  308 + conflict_flag = 0;
  309 + if (hwconfig("usb2")) {
  310 + conflict_flag++;
  311 + cpld_data->soft_mux_on |= SOFT_MUX_ON_CAN3_USB2;
  312 + cpld_data->can3_usb2_mux = PIN_CAN3_USB2_MUX_USB2;
  313 + }
  314 +
  315 + if (hwconfig("can3")) {
  316 + conflict_flag++;
  317 + /* some signals can not enable simultaneous*/
  318 + if (conflict_flag > 1)
  319 + goto conflict;
  320 + cpld_data->soft_mux_on |= SOFT_MUX_ON_CAN3_USB2;
  321 + cpld_data->can3_usb2_mux = PIN_CAN3_USB2_MUX_CAN3;
  322 + }
  323 +
  324 + conflict_flag = 0;
  325 + if (hwconfig("lcd")) {
  326 + conflict_flag++;
  327 + cpld_data->soft_mux_on |= SOFT_MUX_ON_QE_LCD;
  328 + cpld_data->qe_lcd_mux = PIN_QE_LCD_MUX_LCD;
  329 + }
  330 +
  331 + if (hwconfig("qe")) {
  332 + conflict_flag++;
  333 + /* some signals can not enable simultaneous*/
  334 + if (conflict_flag > 1)
  335 + goto conflict;
  336 + cpld_data->soft_mux_on |= SOFT_MUX_ON_QE_LCD;
  337 + cpld_data->qe_lcd_mux = PIN_QE_LCD_MUX_QE;
  338 + }
  339 +
  340 + return 0;
  341 +
  342 +conflict:
  343 + printf("WARNING: pin conflict! MUX setting may failed!\n");
  344 + return 0;
  345 +}
  346 +#endif
  347 +
274 348 int board_early_init_f(void)
275 349 {
276 350 struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
... ... @@ -480,6 +554,10 @@
480 554 #if defined(CONFIG_MISC_INIT_R)
481 555 int misc_init_r(void)
482 556 {
  557 +#ifndef CONFIG_QSPI_BOOT
  558 + config_board_mux();
  559 +#endif
  560 +
483 561 #ifdef CONFIG_FSL_CAAM
484 562 return sec_init();
485 563 #endif