From 45237b5ff0a03dd59bc484a11a2fb5ad3d8b0ea2 Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Wed, 13 Mar 2019 11:56:30 +0100 Subject: ARM: add Zii common directory and move switch reset command The Zii boards share some functionality across different boards. Add a common directory, so we can implement this once and use across different boards. Signed-off-by: Lucas Stach Signed-off-by: Sascha Hauer --- arch/arm/boards/Makefile | 1 + arch/arm/boards/zii-common/Makefile | 1 + arch/arm/boards/zii-common/switch-cmd.c | 49 +++++++++++++++++++++++++++++ arch/arm/boards/zii-imx6q-rdu2/Makefile | 2 +- arch/arm/boards/zii-imx6q-rdu2/switch-cmd.c | 49 ----------------------------- arch/arm/mach-imx/Kconfig | 4 +++ 6 files changed, 56 insertions(+), 50 deletions(-) create mode 100644 arch/arm/boards/zii-common/Makefile create mode 100644 arch/arm/boards/zii-common/switch-cmd.c delete mode 100644 arch/arm/boards/zii-imx6q-rdu2/switch-cmd.c (limited to 'arch') diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile index c5dc41526b..fc883e3dea 100644 --- a/arch/arm/boards/Makefile +++ b/arch/arm/boards/Makefile @@ -156,6 +156,7 @@ obj-$(CONFIG_MACH_QEMU_VIRT64) += qemu-virt64/ obj-$(CONFIG_MACH_WARP7) += element14-warp7/ obj-$(CONFIG_MACH_VF610_TWR) += freescale-vf610-twr/ obj-$(CONFIG_MACH_XILINX_ZCU104) += xilinx-zcu104/ +obj-$(CONFIG_MACH_ZII_COMMON) += zii-common/ obj-$(CONFIG_MACH_ZII_RDU1) += zii-imx51-rdu1/ obj-$(CONFIG_MACH_ZII_RDU2) += zii-imx6q-rdu2/ obj-$(CONFIG_MACH_ZII_IMX8MQ_DEV) += zii-imx8mq-dev/ diff --git a/arch/arm/boards/zii-common/Makefile b/arch/arm/boards/zii-common/Makefile new file mode 100644 index 0000000000..9decfe85fc --- /dev/null +++ b/arch/arm/boards/zii-common/Makefile @@ -0,0 +1 @@ +obj-y += switch-cmd.o diff --git a/arch/arm/boards/zii-common/switch-cmd.c b/arch/arm/boards/zii-common/switch-cmd.c new file mode 100644 index 0000000000..bdba46fb36 --- /dev/null +++ b/arch/arm/boards/zii-common/switch-cmd.c @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2018 Zodiac Inflight Innovation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#include +#include +#include + +static int do_rave_switch_reset(int argc, char *argv[]) +{ + struct i2c_client client; + u8 reg; + + if (!of_machine_is_compatible("zii,imx6q-zii-rdu2") && + !of_machine_is_compatible("zii,imx6qp-zii-rdu2")) + return -ENODEV; + + client.adapter = i2c_get_adapter(1); + if (!client.adapter) + return -ENODEV; + + /* address of the switch watchdog microcontroller */ + client.addr = 0x38; + reg = 0x78; + /* set switch reset time to 100ms */ + i2c_write_reg(&client, 0x0a, ®, 1); + /* reset the switch */ + reg = 0x01; + i2c_write_reg(&client, 0x0d, ®, 1); + /* issue dummy command to work around firmware bug */ + i2c_read_reg(&client, 0x01, ®, 1); + + return 0; +} + +BAREBOX_CMD_START(rave_reset_switch) + .cmd = do_rave_switch_reset, + BAREBOX_CMD_DESC("reset ethernet switch on RDU2") + BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP) +BAREBOX_CMD_END diff --git a/arch/arm/boards/zii-imx6q-rdu2/Makefile b/arch/arm/boards/zii-imx6q-rdu2/Makefile index 10dfba3a3c..c6285362f2 100644 --- a/arch/arm/boards/zii-imx6q-rdu2/Makefile +++ b/arch/arm/boards/zii-imx6q-rdu2/Makefile @@ -1,3 +1,3 @@ -obj-y += board.o switch-cmd.o +obj-y += board.o lwl-y += lowlevel.o bbenv-y += defaultenv-rdu2 diff --git a/arch/arm/boards/zii-imx6q-rdu2/switch-cmd.c b/arch/arm/boards/zii-imx6q-rdu2/switch-cmd.c deleted file mode 100644 index bdba46fb36..0000000000 --- a/arch/arm/boards/zii-imx6q-rdu2/switch-cmd.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2018 Zodiac Inflight Innovation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#include -#include -#include - -static int do_rave_switch_reset(int argc, char *argv[]) -{ - struct i2c_client client; - u8 reg; - - if (!of_machine_is_compatible("zii,imx6q-zii-rdu2") && - !of_machine_is_compatible("zii,imx6qp-zii-rdu2")) - return -ENODEV; - - client.adapter = i2c_get_adapter(1); - if (!client.adapter) - return -ENODEV; - - /* address of the switch watchdog microcontroller */ - client.addr = 0x38; - reg = 0x78; - /* set switch reset time to 100ms */ - i2c_write_reg(&client, 0x0a, ®, 1); - /* reset the switch */ - reg = 0x01; - i2c_write_reg(&client, 0x0d, ®, 1); - /* issue dummy command to work around firmware bug */ - i2c_read_reg(&client, 0x01, ®, 1); - - return 0; -} - -BAREBOX_CMD_START(rave_reset_switch) - .cmd = do_rave_switch_reset, - BAREBOX_CMD_DESC("reset ethernet switch on RDU2") - BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP) -BAREBOX_CMD_END diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig index f3f3a49339..3cfa0c1987 100644 --- a/arch/arm/mach-imx/Kconfig +++ b/arch/arm/mach-imx/Kconfig @@ -431,6 +431,9 @@ config MACH_VF610_TWR bool "Freescale VF610 Tower Board" select ARCH_VF610 +config MACH_ZII_COMMON + bool + config MACH_ZII_RDU1 bool "ZII i.MX51 RDU1" select ARCH_IMX51 @@ -441,6 +444,7 @@ config MACH_ZII_RDU2 bool "ZII i.MX6Q(+) RDU2" select ARCH_IMX6 select MCI_IMX_ESDHC_PBL + select MACH_ZII_COMMON config MACH_ZII_IMX8MQ_DEV bool "ZII i.MX8MQ based devices" -- cgit v1.2.3