1 // SPDX-License-Identifier: GPL-2.0+
3 * Board functions for Compulab CM-FX6 board
5 * Copyright (C) 2014, Compulab Ltd - http://compulab.co.il/
7 * Author: Nikita Kiryanov <nikita@compulab.co.il>
13 #include <dwc_ahsata.h>
15 #include <fsl_esdhc_imx.h>
22 #include <fdt_support.h>
25 #include <asm/arch/crm_regs.h>
26 #include <asm/arch/sys_proto.h>
27 #include <asm/arch/iomux.h>
28 #include <asm/arch/mxc_hdmi.h>
29 #include <asm/mach-imx/mxc_i2c.h>
30 #include <asm/mach-imx/sata.h>
31 #include <asm/mach-imx/video.h>
34 #include <dm/platform_data/serial_mxc.h>
35 #include <dm/device-internal.h>
36 #include <jffs2/load_kernel.h>
38 #include "../common/eeprom.h"
39 #include "../common/common.h"
41 DECLARE_GLOBAL_DATA_PTR;
43 #ifdef CONFIG_SPLASH_SCREEN
44 static struct splash_location cm_fx6_splash_locations[] = {
47 .storage = SPLASH_STORAGE_SF,
48 .flags = SPLASH_STORAGE_RAW,
53 .storage = SPLASH_STORAGE_MMC,
54 .flags = SPLASH_STORAGE_FS,
59 .storage = SPLASH_STORAGE_USB,
60 .flags = SPLASH_STORAGE_FS,
65 .storage = SPLASH_STORAGE_SATA,
66 .flags = SPLASH_STORAGE_FS,
71 int splash_screen_prepare(void)
73 return splash_source_load(cm_fx6_splash_locations,
74 ARRAY_SIZE(cm_fx6_splash_locations));
78 #ifdef CONFIG_IMX_HDMI
79 static void cm_fx6_enable_hdmi(struct display_info_t const *dev)
81 struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
83 setbits_le32(&mxc_ccm->CCGR3, MXC_CCM_CCGR3_IPU1_IPU_DI0_MASK);
84 imx_enable_hdmi_phy();
87 static struct display_info_t preset_hdmi_1024X768 = {
90 .pixfmt = IPU_PIX_FMT_RGB24,
91 .enable = cm_fx6_enable_hdmi,
105 .vmode = FB_VMODE_NONINTERLACED,
109 static void cm_fx6_setup_display(void)
111 struct iomuxc *const iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
114 clrbits_le32(&iomuxc_regs->gpr[3], MXC_CCM_CCGR3_IPU1_IPU_DI0_MASK);
117 int board_video_skip(void)
120 struct display_info_t *preset;
121 char const *panel = env_get("displaytype");
123 if (!panel) /* Also accept panel for backward compatibility */
124 panel = env_get("panel");
129 if (!strcmp(panel, "HDMI"))
130 preset = &preset_hdmi_1024X768;
134 ret = ipuv3_fb_init(&preset->mode, 0, preset->pixfmt);
136 printf("Can't init display %s: %d\n", preset->mode.name, ret);
140 preset->enable(preset);
141 printf("Display: %s (%ux%u)\n", preset->mode.name, preset->mode.xres,
147 static inline void cm_fx6_setup_display(void) {}
148 #endif /* CONFIG_VIDEO_IPUV3 */
150 int ipu_displays_init(void)
152 return board_video_skip();
155 #ifdef CONFIG_DWC_AHSATA
156 static int cm_fx6_issd_gpios[] = {
157 /* The order of the GPIOs in the array is important! */
162 CM_FX6_SATA_NSTANDBY1,
163 CM_FX6_SATA_NSTANDBY2,
166 static void cm_fx6_sata_power(int on)
170 if (!on) { /* tell the iSSD that the power will be removed */
171 gpio_direction_output(CM_FX6_SATA_PWLOSS_INT, 1);
175 for (i = 0; i < ARRAY_SIZE(cm_fx6_issd_gpios); i++) {
176 gpio_direction_output(cm_fx6_issd_gpios[i], on);
180 if (!on) /* for compatibility lower the power loss interrupt */
181 gpio_direction_output(CM_FX6_SATA_PWLOSS_INT, 0);
184 static iomux_v3_cfg_t const sata_pads[] = {
186 IOMUX_PADS(PAD_ENET_TX_EN__GPIO1_IO28 | MUX_PAD_CTRL(NO_PAD_CTRL)),
187 IOMUX_PADS(PAD_EIM_A22__GPIO2_IO16 | MUX_PAD_CTRL(NO_PAD_CTRL)),
188 IOMUX_PADS(PAD_EIM_D20__GPIO3_IO20 | MUX_PAD_CTRL(NO_PAD_CTRL)),
189 IOMUX_PADS(PAD_EIM_A25__GPIO5_IO02 | MUX_PAD_CTRL(NO_PAD_CTRL)),
191 IOMUX_PADS(PAD_ENET_TXD0__GPIO1_IO30 | MUX_PAD_CTRL(NO_PAD_CTRL)),
192 IOMUX_PADS(PAD_EIM_D23__GPIO3_IO23 | MUX_PAD_CTRL(NO_PAD_CTRL)),
193 IOMUX_PADS(PAD_EIM_D29__GPIO3_IO29 | MUX_PAD_CTRL(NO_PAD_CTRL)),
194 IOMUX_PADS(PAD_EIM_A23__GPIO6_IO06 | MUX_PAD_CTRL(NO_PAD_CTRL)),
195 IOMUX_PADS(PAD_EIM_BCLK__GPIO6_IO31 | MUX_PAD_CTRL(NO_PAD_CTRL)),
198 static int cm_fx6_setup_issd(void)
202 SETUP_IOMUX_PADS(sata_pads);
204 for (i = 0; i < ARRAY_SIZE(cm_fx6_issd_gpios); i++) {
205 ret = gpio_request(cm_fx6_issd_gpios[i], "sata");
210 ret = gpio_request(CM_FX6_SATA_PWLOSS_INT, "sata_pwloss_int");
217 #define CM_FX6_SATA_INIT_RETRIES 10
220 static int cm_fx6_setup_issd(void) { return 0; }
223 #ifdef CONFIG_SYS_I2C_MXC
224 #define I2C_PAD_CTRL (PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
225 PAD_CTL_DSE_40ohm | PAD_CTL_HYS | \
226 PAD_CTL_ODE | PAD_CTL_SRE_FAST)
229 PAD_EIM_D21__I2C1_SCL | MUX_PAD_CTRL(I2C_PAD_CTRL),
230 PAD_EIM_D21__GPIO3_IO21 | MUX_PAD_CTRL(I2C_PAD_CTRL),
232 PAD_EIM_D28__I2C1_SDA | MUX_PAD_CTRL(I2C_PAD_CTRL),
233 PAD_EIM_D28__GPIO3_IO28 | MUX_PAD_CTRL(I2C_PAD_CTRL),
237 PAD_KEY_COL3__I2C2_SCL | MUX_PAD_CTRL(I2C_PAD_CTRL),
238 PAD_KEY_COL3__GPIO4_IO12 | MUX_PAD_CTRL(I2C_PAD_CTRL),
240 PAD_KEY_ROW3__I2C2_SDA | MUX_PAD_CTRL(I2C_PAD_CTRL),
241 PAD_KEY_ROW3__GPIO4_IO13 | MUX_PAD_CTRL(I2C_PAD_CTRL),
245 PAD_GPIO_3__I2C3_SCL | MUX_PAD_CTRL(I2C_PAD_CTRL),
246 PAD_GPIO_3__GPIO1_IO03 | MUX_PAD_CTRL(I2C_PAD_CTRL),
248 PAD_GPIO_6__I2C3_SDA | MUX_PAD_CTRL(I2C_PAD_CTRL),
249 PAD_GPIO_6__GPIO1_IO06 | MUX_PAD_CTRL(I2C_PAD_CTRL),
253 static int cm_fx6_setup_one_i2c(int busnum, struct i2c_pads_info *pads)
257 ret = setup_i2c(busnum, CONFIG_SYS_I2C_SPEED, 0x7f, pads);
259 printf("Warning: I2C%d setup failed: %d\n", busnum, ret);
264 static int cm_fx6_setup_i2c(void)
268 /* i2c<x>_pads are wierd macro variables; we can't use an array */
269 err = cm_fx6_setup_one_i2c(0, I2C_PADS_INFO(i2c0_pads));
272 err = cm_fx6_setup_one_i2c(1, I2C_PADS_INFO(i2c1_pads));
275 err = cm_fx6_setup_one_i2c(2, I2C_PADS_INFO(i2c2_pads));
282 static int cm_fx6_setup_i2c(void) { return 0; }
285 #ifdef CONFIG_USB_EHCI_MX6
286 #define WEAK_PULLDOWN (PAD_CTL_PUS_100K_DOWN | \
287 PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | \
288 PAD_CTL_HYS | PAD_CTL_SRE_SLOW)
289 #define MX6_USBNC_BASEADDR 0x2184800
290 #define USBNC_USB_H1_PWR_POL (1 << 9)
292 static int cm_fx6_setup_usb_host(void)
296 err = gpio_request(CM_FX6_USB_HUB_RST, "usb hub rst");
300 SETUP_IOMUX_PAD(PAD_GPIO_0__USB_H1_PWR | MUX_PAD_CTRL(NO_PAD_CTRL));
301 SETUP_IOMUX_PAD(PAD_SD3_RST__GPIO7_IO08 | MUX_PAD_CTRL(NO_PAD_CTRL));
306 static int cm_fx6_setup_usb_otg(void)
309 struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
311 err = gpio_request(SB_FX6_USB_OTG_PWR, "usb-pwr");
313 printf("USB OTG pwr gpio request failed: %d\n", err);
317 SETUP_IOMUX_PAD(PAD_EIM_D22__GPIO3_IO22 | MUX_PAD_CTRL(NO_PAD_CTRL));
318 SETUP_IOMUX_PAD(PAD_ENET_RX_ER__USB_OTG_ID |
319 MUX_PAD_CTRL(WEAK_PULLDOWN));
320 clrbits_le32(&iomux->gpr[1], IOMUXC_GPR1_OTG_ID_MASK);
321 /* disable ext. charger detect, or it'll affect signal quality at dp. */
322 return gpio_direction_output(SB_FX6_USB_OTG_PWR, 0);
325 int board_usb_phy_mode(int port)
327 return USB_INIT_HOST;
330 int board_ehci_hcd_init(int port)
333 u32 *usbnc_usb_uh1_ctrl = (u32 *)(MX6_USBNC_BASEADDR + 4);
335 /* Only 1 host controller in use. port 0 is OTG & needs no attention */
339 /* Set PWR polarity to match power switch's enable polarity */
340 setbits_le32(usbnc_usb_uh1_ctrl, USBNC_USB_H1_PWR_POL);
341 ret = gpio_direction_output(CM_FX6_USB_HUB_RST, 0);
346 ret = gpio_direction_output(CM_FX6_USB_HUB_RST, 1);
355 int board_ehci_power(int port, int on)
358 return gpio_direction_output(SB_FX6_USB_OTG_PWR, on);
363 static int cm_fx6_setup_usb_otg(void) { return 0; }
364 static int cm_fx6_setup_usb_host(void) { return 0; }
367 #ifdef CONFIG_FEC_MXC
368 #define ENET_PAD_CTRL (PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
369 PAD_CTL_DSE_40ohm | PAD_CTL_HYS)
371 static int mx6_rgmii_rework(struct phy_device *phydev)
375 /* Ar8031 phy SmartEEE feature cause link status generates glitch,
376 * which cause ethernet link down/up issue, so disable SmartEEE
378 phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x3);
379 phy_write(phydev, MDIO_DEVAD_NONE, 0xe, 0x805d);
380 phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x4003);
381 val = phy_read(phydev, MDIO_DEVAD_NONE, 0xe);
383 phy_write(phydev, MDIO_DEVAD_NONE, 0xe, val);
385 /* To enable AR8031 ouput a 125MHz clk from CLK_25M */
386 phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x7);
387 phy_write(phydev, MDIO_DEVAD_NONE, 0xe, 0x8016);
388 phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x4007);
390 val = phy_read(phydev, MDIO_DEVAD_NONE, 0xe);
393 phy_write(phydev, MDIO_DEVAD_NONE, 0xe, val);
395 /* introduce tx clock delay */
396 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x5);
397 val = phy_read(phydev, MDIO_DEVAD_NONE, 0x1e);
399 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, val);
404 int board_phy_config(struct phy_device *phydev)
406 mx6_rgmii_rework(phydev);
408 if (phydev->drv->config)
409 return phydev->drv->config(phydev);
414 static iomux_v3_cfg_t const enet_pads[] = {
415 IOMUX_PADS(PAD_ENET_MDIO__ENET_MDIO | MUX_PAD_CTRL(ENET_PAD_CTRL)),
416 IOMUX_PADS(PAD_ENET_MDC__ENET_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL)),
417 IOMUX_PADS(PAD_RGMII_TXC__RGMII_TXC | MUX_PAD_CTRL(ENET_PAD_CTRL)),
418 IOMUX_PADS(PAD_RGMII_TD0__RGMII_TD0 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
419 IOMUX_PADS(PAD_RGMII_TD1__RGMII_TD1 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
420 IOMUX_PADS(PAD_RGMII_TD2__RGMII_TD2 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
421 IOMUX_PADS(PAD_RGMII_TD3__RGMII_TD3 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
422 IOMUX_PADS(PAD_RGMII_RXC__RGMII_RXC | MUX_PAD_CTRL(ENET_PAD_CTRL)),
423 IOMUX_PADS(PAD_RGMII_RD0__RGMII_RD0 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
424 IOMUX_PADS(PAD_RGMII_RD1__RGMII_RD1 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
425 IOMUX_PADS(PAD_RGMII_RD2__RGMII_RD2 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
426 IOMUX_PADS(PAD_RGMII_RD3__RGMII_RD3 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
427 IOMUX_PADS(PAD_GPIO_0__CCM_CLKO1 | MUX_PAD_CTRL(NO_PAD_CTRL)),
428 IOMUX_PADS(PAD_GPIO_3__CCM_CLKO2 | MUX_PAD_CTRL(NO_PAD_CTRL)),
429 IOMUX_PADS(PAD_SD4_DAT0__GPIO2_IO08 | MUX_PAD_CTRL(0x84)),
430 IOMUX_PADS(PAD_ENET_REF_CLK__ENET_TX_CLK |
431 MUX_PAD_CTRL(ENET_PAD_CTRL)),
432 IOMUX_PADS(PAD_RGMII_TX_CTL__RGMII_TX_CTL |
433 MUX_PAD_CTRL(ENET_PAD_CTRL)),
434 IOMUX_PADS(PAD_RGMII_RX_CTL__RGMII_RX_CTL |
435 MUX_PAD_CTRL(ENET_PAD_CTRL)),
438 static int handle_mac_address(char *env_var, uint eeprom_bus)
440 unsigned char enetaddr[6];
443 rc = eth_env_get_enetaddr(env_var, enetaddr);
447 rc = cl_eeprom_read_mac_addr(enetaddr, eeprom_bus);
451 if (!is_valid_ethaddr(enetaddr))
454 return eth_env_set_enetaddr(env_var, enetaddr);
457 #define SB_FX6_I2C_EEPROM_BUS 0
458 #define NO_MAC_ADDR "No MAC address found for %s\n"
459 int board_eth_init(bd_t *bis)
463 if (handle_mac_address("ethaddr", CONFIG_SYS_I2C_EEPROM_BUS))
464 printf(NO_MAC_ADDR, "primary NIC");
466 if (handle_mac_address("eth1addr", SB_FX6_I2C_EEPROM_BUS))
467 printf(NO_MAC_ADDR, "secondary NIC");
469 SETUP_IOMUX_PADS(enet_pads);
471 err = gpio_request(CM_FX6_ENET_NRST, "enet_nrst");
473 printf("Etnernet NRST gpio request failed: %d\n", err);
474 gpio_direction_output(CM_FX6_ENET_NRST, 0);
476 gpio_set_value(CM_FX6_ENET_NRST, 1);
478 return cpu_eth_init(bis);
482 #ifdef CONFIG_NAND_MXS
483 static iomux_v3_cfg_t const nand_pads[] = {
484 IOMUX_PADS(PAD_NANDF_CLE__NAND_CLE | MUX_PAD_CTRL(NO_PAD_CTRL)),
485 IOMUX_PADS(PAD_NANDF_ALE__NAND_ALE | MUX_PAD_CTRL(NO_PAD_CTRL)),
486 IOMUX_PADS(PAD_NANDF_CS0__NAND_CE0_B | MUX_PAD_CTRL(NO_PAD_CTRL)),
487 IOMUX_PADS(PAD_NANDF_RB0__NAND_READY_B | MUX_PAD_CTRL(NO_PAD_CTRL)),
488 IOMUX_PADS(PAD_NANDF_D0__NAND_DATA00 | MUX_PAD_CTRL(NO_PAD_CTRL)),
489 IOMUX_PADS(PAD_NANDF_D1__NAND_DATA01 | MUX_PAD_CTRL(NO_PAD_CTRL)),
490 IOMUX_PADS(PAD_NANDF_D2__NAND_DATA02 | MUX_PAD_CTRL(NO_PAD_CTRL)),
491 IOMUX_PADS(PAD_NANDF_D3__NAND_DATA03 | MUX_PAD_CTRL(NO_PAD_CTRL)),
492 IOMUX_PADS(PAD_NANDF_D4__NAND_DATA04 | MUX_PAD_CTRL(NO_PAD_CTRL)),
493 IOMUX_PADS(PAD_NANDF_D5__NAND_DATA05 | MUX_PAD_CTRL(NO_PAD_CTRL)),
494 IOMUX_PADS(PAD_NANDF_D6__NAND_DATA06 | MUX_PAD_CTRL(NO_PAD_CTRL)),
495 IOMUX_PADS(PAD_NANDF_D7__NAND_DATA07 | MUX_PAD_CTRL(NO_PAD_CTRL)),
496 IOMUX_PADS(PAD_SD4_CMD__NAND_RE_B | MUX_PAD_CTRL(NO_PAD_CTRL)),
497 IOMUX_PADS(PAD_SD4_CLK__NAND_WE_B | MUX_PAD_CTRL(NO_PAD_CTRL)),
500 static void cm_fx6_setup_gpmi_nand(void)
502 SETUP_IOMUX_PADS(nand_pads);
503 /* Enable clock roots */
504 enable_usdhc_clk(1, 3);
505 enable_usdhc_clk(1, 4);
507 setup_gpmi_io_clk(MXC_CCM_CS2CDR_ENFC_CLK_PODF(0xf) |
508 MXC_CCM_CS2CDR_ENFC_CLK_PRED(1) |
509 MXC_CCM_CS2CDR_ENFC_CLK_SEL(0));
512 static void cm_fx6_setup_gpmi_nand(void) {}
515 #ifdef CONFIG_MXC_SPI
516 int cm_fx6_setup_ecspi(void)
518 cm_fx6_set_ecspi_iomux();
519 return gpio_request(CM_FX6_ECSPI_BUS0_CS0, "ecspi_bus0_cs0");
522 int cm_fx6_setup_ecspi(void) { return 0; }
525 #ifdef CONFIG_OF_BOARD_SETUP
526 #define USDHC3_PATH "/soc/aips-bus@02100000/usdhc@02198000/"
528 static const struct node_info nodes[] = {
530 * Both entries target the same flash chip. The st,m25p compatible
531 * is used in the vendor device trees, while upstream uses (the
532 * documented) jedec,spi-nor compatible.
534 { "st,m25p", MTD_DEV_TYPE_NOR, },
535 { "jedec,spi-nor", MTD_DEV_TYPE_NOR, },
538 int ft_board_setup(void *blob, bd_t *bd)
543 char baseboard_name[16];
546 fdt_shrink_to_minimum(blob, 0); /* Make room for new properties */
549 if (eth_env_get_enetaddr("ethaddr", enetaddr)) {
550 fdt_find_and_setprop(blob,
551 "/soc/aips-bus@02100000/ethernet@02188000",
552 "local-mac-address", enetaddr, 6, 1);
555 if (eth_env_get_enetaddr("eth1addr", enetaddr)) {
556 fdt_find_and_setprop(blob, "/eth@pcie", "local-mac-address",
560 fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
562 baseboard_rev = cl_eeprom_get_board_rev(0);
563 err = cl_eeprom_get_product_name((uchar *)baseboard_name, 0);
564 if (err || baseboard_rev == 0)
565 return 0; /* Assume not an early revision SB-FX6m baseboard */
567 if (!strncmp("SB-FX6m", baseboard_name, 7) && baseboard_rev <= 120) {
568 nodeoffset = fdt_path_offset(blob, USDHC3_PATH);
569 fdt_delprop(blob, nodeoffset, "cd-gpios");
570 fdt_find_and_setprop(blob, USDHC3_PATH, "broken-cd",
572 fdt_find_and_setprop(blob, USDHC3_PATH, "keep-power-in-suspend",
584 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
585 cm_fx6_setup_gpmi_nand();
587 ret = cm_fx6_setup_ecspi();
589 printf("Warning: ECSPI setup failed: %d\n", ret);
591 ret = cm_fx6_setup_usb_otg();
593 printf("Warning: USB OTG setup failed: %d\n", ret);
595 ret = cm_fx6_setup_usb_host();
597 printf("Warning: USB host setup failed: %d\n", ret);
600 * cm-fx6 may have iSSD not assembled and in this case it has
601 * bypasses for a (m)SATA socket on the baseboard. The socketed
602 * device is not controlled by those GPIOs. So just print a warning
603 * if the setup fails.
605 ret = cm_fx6_setup_issd();
607 printf("Warning: iSSD setup failed: %d\n", ret);
609 /* Warn on failure but do not abort boot */
610 ret = cm_fx6_setup_i2c();
612 printf("Warning: I2C setup failed: %d\n", ret);
614 cm_fx6_setup_display();
616 /* This should be done in the MMC driver when MX6 has a clock driver */
617 #ifdef CONFIG_FSL_ESDHC_IMX
618 if (IS_ENABLED(CONFIG_BLK)) {
621 cm_fx6_set_usdhc_iomux();
622 for (i = 0; i < CONFIG_SYS_FSL_USDHC_NUM; i++)
623 enable_usdhc_clk(1, i);
630 int board_late_init(void)
632 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
633 char baseboard_name[16];
637 env_set("board_rev", "MX6Q");
639 env_set("board_rev", "MX6DL");
641 err = cl_eeprom_get_product_name((uchar *)baseboard_name, 0);
645 if (!strncmp("SB-FX6m", baseboard_name, 7))
646 env_set("board_name", "Utilite");
653 puts("Board: CM-FX6\n");
657 int misc_init_r(void)
664 int dram_init_banksize(void)
666 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
667 gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
669 switch (gd->ram_size) {
670 case 0x10000000: /* DDR_16BIT_256MB */
671 gd->bd->bi_dram[0].size = 0x10000000;
672 gd->bd->bi_dram[1].size = 0;
674 case 0x20000000: /* DDR_32BIT_512MB */
675 gd->bd->bi_dram[0].size = 0x20000000;
676 gd->bd->bi_dram[1].size = 0;
679 if (is_cpu_type(MXC_CPU_MX6SOLO)) { /* DDR_32BIT_1GB */
680 gd->bd->bi_dram[0].size = 0x20000000;
681 gd->bd->bi_dram[1].size = 0x20000000;
682 } else { /* DDR_64BIT_1GB */
683 gd->bd->bi_dram[0].size = 0x40000000;
684 gd->bd->bi_dram[1].size = 0;
687 case 0x80000000: /* DDR_64BIT_2GB */
688 gd->bd->bi_dram[0].size = 0x40000000;
689 gd->bd->bi_dram[1].size = 0x40000000;
691 case 0xEFF00000: /* DDR_64BIT_4GB */
692 gd->bd->bi_dram[0].size = 0x70000000;
693 gd->bd->bi_dram[1].size = 0x7FF00000;
702 gd->ram_size = imx_ddr_size();
703 switch (gd->ram_size) {
710 gd->ram_size -= 0x100000;
713 printf("ERROR: Unsupported DRAM size 0x%lx\n", gd->ram_size);
720 u32 get_board_rev(void)
722 return cl_eeprom_get_board_rev(CONFIG_SYS_I2C_EEPROM_BUS);
725 static struct mxc_serial_platdata cm_fx6_mxc_serial_plat = {
726 .reg = (struct mxc_uart *)UART4_BASE,
729 U_BOOT_DEVICE(cm_fx6_serial) = {
730 .name = "serial_mxc",
731 .platdata = &cm_fx6_mxc_serial_plat,
734 #if CONFIG_IS_ENABLED(AHCI)
735 static int sata_imx_probe(struct udevice *dev)
739 /* Make sure this gpio has logical 0 value */
740 gpio_direction_output(CM_FX6_SATA_PWLOSS_INT, 0);
742 cm_fx6_sata_power(1);
744 for (i = 0; i < CM_FX6_SATA_INIT_RETRIES; i++) {
747 printf("SATA setup failed: %d\n", err);
753 err = dwc_ahsata_probe(dev);
757 /* There is no device on the SATA port */
758 if (sata_dm_port_status(0, 0) == 0)
761 /* There's a device, but link not established. Retry */
762 device_remove(dev, DM_REMOVE_NORMAL);
768 static int sata_imx_remove(struct udevice *dev)
770 cm_fx6_sata_power(0);
776 struct ahci_ops sata_imx_ops = {
777 .port_status = dwc_ahsata_port_status,
778 .reset = dwc_ahsata_bus_reset,
779 .scan = dwc_ahsata_scan,
782 static const struct udevice_id sata_imx_ids[] = {
783 { .compatible = "fsl,imx6q-ahci" },
787 U_BOOT_DRIVER(sata_imx) = {
790 .of_match = sata_imx_ids,
791 .ops = &sata_imx_ops,
792 .probe = sata_imx_probe,
793 .remove = sata_imx_remove, /* reset bus to stop it */