ARM: mx5: dynamically register imx-i2c devices
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-mx5 / board-mx51_babbage.c
index 6e384d92e625d107279c14228964553525aa6c53..3f3075d7768f5072ead441ca271d8e143b8bac2a 100644 (file)
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/fsl_devices.h>
+#include <linux/fec.h>
 
 #include <mach/common.h>
 #include <mach/hardware.h>
 #include <mach/imx-uart.h>
 #include <mach/iomux-mx51.h>
-#include <mach/i2c.h>
 #include <mach/mxc_ehci.h>
 
 #include <asm/irq.h>
@@ -35,7 +35,8 @@
 
 #define BABBAGE_USB_HUB_RESET  (0*32 + 7)      /* GPIO_1_7 */
 #define BABBAGE_USBH1_STP      (0*32 + 27)     /* GPIO_1_27 */
-#define BABBAGE_PHY_RESET (1*32 +5)    /* GPIO_2_5 */
+#define BABBAGE_PHY_RESET      (1*32 + 5)      /* GPIO_2_5 */
+#define BABBAGE_FEC_PHY_RESET  (1*32 + 14)     /* GPIO_2_14 */
 
 /* USB_CTRL_1 */
 #define MX51_USB_CTRL_1_OFFSET                 0x10
@@ -93,6 +94,28 @@ static struct pad_desc mx51babbage_pads[] = {
 
        /* USB HUB reset line*/
        MX51_PAD_GPIO_1_7__GPIO_1_7,
+
+       /* FEC */
+       MX51_PAD_EIM_EB2__FEC_MDIO,
+       MX51_PAD_EIM_EB3__FEC_RDAT1,
+       MX51_PAD_EIM_CS2__FEC_RDAT2,
+       MX51_PAD_EIM_CS3__FEC_RDAT3,
+       MX51_PAD_EIM_CS4__FEC_RX_ER,
+       MX51_PAD_EIM_CS5__FEC_CRS,
+       MX51_PAD_NANDF_RB2__FEC_COL,
+       MX51_PAD_NANDF_RB3__FEC_RXCLK,
+       MX51_PAD_NANDF_RB6__FEC_RDAT0,
+       MX51_PAD_NANDF_RB7__FEC_TDAT0,
+       MX51_PAD_NANDF_CS2__FEC_TX_ER,
+       MX51_PAD_NANDF_CS3__FEC_MDC,
+       MX51_PAD_NANDF_CS4__FEC_TDAT1,
+       MX51_PAD_NANDF_CS5__FEC_TDAT2,
+       MX51_PAD_NANDF_CS6__FEC_TDAT3,
+       MX51_PAD_NANDF_CS7__FEC_TX_EN,
+       MX51_PAD_NANDF_RDY_INT__FEC_TX_CLK,
+
+       /* FEC PHY reset line */
+       MX51_PAD_EIM_A20__GPIO_2_14,
 };
 
 /* Serial ports */
@@ -113,7 +136,7 @@ static inline void mxc_init_imx_uart(void)
 }
 #endif /* SERIAL_IMX */
 
-static struct imxi2c_platform_data babbage_i2c_data = {
+static const struct imxi2c_platform_data babbage_i2c_data __initconst = {
        .bitrate = 100000,
 };
 
@@ -171,6 +194,22 @@ static inline void babbage_usbhub_reset(void)
        gpio_set_value(BABBAGE_USB_HUB_RESET, 1);
 }
 
+static inline void babbage_fec_reset(void)
+{
+       int ret;
+
+       /* reset FEC PHY */
+       ret = gpio_request(BABBAGE_FEC_PHY_RESET, "fec-phy-reset");
+       if (ret) {
+               printk(KERN_ERR"failed to get GPIO_FEC_PHY_RESET: %d\n", ret);
+               return;
+       }
+       gpio_direction_output(BABBAGE_FEC_PHY_RESET, 0);
+       gpio_set_value(BABBAGE_FEC_PHY_RESET, 0);
+       msleep(1);
+       gpio_set_value(BABBAGE_FEC_PHY_RESET, 1);
+}
+
 /* This function is board specific as the bit mask for the plldiv will also
 be different for other Freescale SoCs, thus a common bitmask is not
 possible and cannot get place in /plat-mxc/ehci.c.*/
@@ -178,7 +217,7 @@ static int initialize_otg_port(struct platform_device *pdev)
 {
        u32 v;
        void __iomem *usb_base;
-       u32 usbother_base;
+       void __iomem *usbother_base;
 
        usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K);
        usbother_base = usb_base + MX5_USBOTHER_REGS_OFFSET;
@@ -196,7 +235,7 @@ static int initialize_usbh1_port(struct platform_device *pdev)
 {
        u32 v;
        void __iomem *usb_base;
-       u32 usbother_base;
+       void __iomem *usbother_base;
 
        usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K);
        usbother_base = usb_base + MX5_USBOTHER_REGS_OFFSET;
@@ -250,10 +289,11 @@ static void __init mxc_board_init(void)
        mxc_iomux_v3_setup_multiple_pads(mx51babbage_pads,
                                        ARRAY_SIZE(mx51babbage_pads));
        mxc_init_imx_uart();
+       babbage_fec_reset();
        platform_add_devices(devices, ARRAY_SIZE(devices));
 
-       mxc_register_device(&mxc_i2c_device0, &babbage_i2c_data);
-       mxc_register_device(&mxc_i2c_device1, &babbage_i2c_data);
+       imx51_add_imx_i2c(0, &babbage_i2c_data);
+       imx51_add_imx_i2c(1, &babbage_i2c_data);
        mxc_register_device(&mxc_hsi2c_device, &babbage_hsi2c_data);
 
        if (otg_mode_host)
@@ -283,7 +323,7 @@ MACHINE_START(MX51_BABBAGE, "Freescale MX51 Babbage Board")
        /* Maintainer: Amit Kucheria <amit.kucheria@canonical.com> */
        .phys_io = MX51_AIPS1_BASE_ADDR,
        .io_pg_offst = ((MX51_AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
-       .boot_params = PHYS_OFFSET + 0x100,
+       .boot_params = MX51_PHYS_OFFSET + 0x100,
        .map_io = mx51_map_io,
        .init_irq = mx51_init_irq,
        .init_machine = mxc_board_init,