diff options
189 files changed, 2653 insertions, 2149 deletions
@@ -1,5 +1,5 @@ VERSION = 2013 -PATCHLEVEL = 04 +PATCHLEVEL = 05 SUBLEVEL = 0 EXTRAVERSION = NAME = Amissive Actinocutious Kiwi @@ -667,9 +667,6 @@ define rule_barebox-modpost $(Q)echo 'cmd_$@ := $(cmd_barebox-modpost)' > $(dot-target).cmd endef -quiet_cmd_objcopy = OBJCOPY $@ - cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ - OBJCOPYFLAGS_barebox.bin = -O binary barebox.bin: barebox FORCE @@ -841,13 +838,19 @@ include/asm: $(Q)$(check-symlink) $(Q)$(create-symlink) +define symlink-config-h + if [ -f $(srctree)/$(BOARD)/config.h ]; then \ + $(kecho) ' SYMLINK $@ -> $(BOARD)/config.h'; \ + ln -fsn $(srctree)/$(BOARD)/config.h $@; \ + else \ + [ -h $@ ] && rm -f $@; \ + $(kecho) ' CREATE $@'; \ + touch -a $@; \ + fi +endef + include/config.h: include/config/auto.conf - $(Q)$(kecho) ' SYMLINK $@ -> $(BOARD)/config.h' -ifneq ($(KBUILD_SRC),) - $(Q)ln -fsn $(srctree)/$(BOARD)/config.h $@ -else - $(Q)ln -fsn ../$(BOARD)/config.h $@ -endif + $(Q)$(symlink-config-h) # Generate some files # --------------------------------------------------------------------------- diff --git a/arch/arm/boards/archosg9/config.h b/arch/arm/boards/archosg9/config.h deleted file mode 100644 index da84fa5f6b..0000000000 --- a/arch/arm/boards/archosg9/config.h +++ /dev/null @@ -1 +0,0 @@ -/* nothing */ diff --git a/arch/arm/boards/at91sam9m10g45ek/init.c b/arch/arm/boards/at91sam9m10g45ek/init.c index f32215deef..d9a2f1f28f 100644 --- a/arch/arm/boards/at91sam9m10g45ek/init.c +++ b/arch/arm/boards/at91sam9m10g45ek/init.c @@ -38,6 +38,7 @@ #include <mach/at91sam9_smc.h> #include <gpio_keys.h> #include <readkey.h> +#include <spi/spi.h> /* * board revision encoding @@ -125,6 +126,22 @@ static void ek_add_device_mci(void) static void ek_add_device_mci(void) {} #endif +static const struct spi_board_info ek_spi_devices[] = { + { + .name = "mtd_dataflash", + .chip_select = 0, + .max_speed_hz = 15 * 1000 * 1000, + .bus_num = 0, + } +}; + +static void ek_add_device_spi(void) +{ + spi_register_board_info(ek_spi_devices, + ARRAY_SIZE(ek_spi_devices)); + at91_add_device_spi(0, NULL); +} + #ifdef CONFIG_LED_GPIO struct gpio_led ek_leds[] = { { @@ -281,6 +298,7 @@ static void ek_add_device_lcdc(void) {} static int at91sam9m10g45ek_devices_init(void) { ek_add_device_nand(); + ek_add_device_spi(); at91_add_device_eth(0, &macb_pdata); ek_add_device_mci(); ek_add_device_usb(); diff --git a/arch/arm/boards/at91sam9m10ihd/hw_version.c b/arch/arm/boards/at91sam9m10ihd/hw_version.c index be910dfbc0..8e729013c7 100644 --- a/arch/arm/boards/at91sam9m10ihd/hw_version.c +++ b/arch/arm/boards/at91sam9m10ihd/hw_version.c @@ -194,10 +194,8 @@ static void at91sam9m10ihd_devices_detect_one(const char *name) dev_add_param_fixed(dev, "board", info.board_name); sprintf(str, "%.2s", info.vendor_country); dev_add_param_fixed(dev, "country", str); - sprintf(str, "%d", info.year); - dev_add_param_fixed(dev, "year", str); - sprintf(str, "%d", info.week); - dev_add_param_fixed(dev, "week", str); + dev_add_param_int_ro(dev, "year", info.year, "%d"); + dev_add_param_int_ro(dev, "week", info.week, "%d"); sprintf(str, "%c", info.revision_code); dev_add_param_fixed(dev, "revision_code", str); sprintf(str, "%c", info.revision_id); diff --git a/arch/arm/boards/at91sam9x5ek/hw_version.c b/arch/arm/boards/at91sam9x5ek/hw_version.c index 76d4e1b8fa..91af331194 100644 --- a/arch/arm/boards/at91sam9x5ek/hw_version.c +++ b/arch/arm/boards/at91sam9x5ek/hw_version.c @@ -219,10 +219,8 @@ static void at91sam9x5ek_devices_detect_one(const char *name) dev_add_param_fixed(dev, "board", info.board_name); sprintf(str, "%.2s", info.vendor_country); dev_add_param_fixed(dev, "country", str); - sprintf(str, "%d", info.year); - dev_add_param_fixed(dev, "year", str); - sprintf(str, "%d", info.week); - dev_add_param_fixed(dev, "week", str); + dev_add_param_int_ro(dev, "year", info.year, "%d"); + dev_add_param_int_ro(dev, "week", info.week, "%d"); sprintf(str, "%c", info.revision_code); dev_add_param_fixed(dev, "revision_code", str); sprintf(str, "%c", info.revision_id); diff --git a/arch/arm/boards/avnet-zedboard/config.h b/arch/arm/boards/avnet-zedboard/config.h deleted file mode 100644 index ca15136817..0000000000 --- a/arch/arm/boards/avnet-zedboard/config.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/beagle/config.h b/arch/arm/boards/beagle/config.h deleted file mode 100644 index 143adf2552..0000000000 --- a/arch/arm/boards/beagle/config.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - * 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. - * - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/beaglebone/config.h b/arch/arm/boards/beaglebone/config.h deleted file mode 100644 index 252aa79ae7..0000000000 --- a/arch/arm/boards/beaglebone/config.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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. - * - */ - -#ifndef _CONFIG_H_ -# define _CONFIG_H_ - -#endif /* _CONFIG_H_ */ diff --git a/arch/arm/boards/beaglebone/lowlevel.c b/arch/arm/boards/beaglebone/lowlevel.c index a9737d9f93..28959ff9ab 100644 --- a/arch/arm/boards/beaglebone/lowlevel.c +++ b/arch/arm/boards/beaglebone/lowlevel.c @@ -55,7 +55,7 @@ static void beaglebone_data_macro_config(int dataMacroNum) { - u32 BaseAddrOffset = 0x00;; + u32 BaseAddrOffset = 0x00; if (dataMacroNum == 1) BaseAddrOffset = 0xA4; diff --git a/arch/arm/boards/ccxmx51/ccxmx51.c b/arch/arm/boards/ccxmx51/ccxmx51.c index a14c9bc876..df565d97d5 100644 --- a/arch/arm/boards/ccxmx51/ccxmx51.c +++ b/arch/arm/boards/ccxmx51/ccxmx51.c @@ -196,7 +196,8 @@ static const struct spi_board_info ccxmx51_spi_board_info[] = { }; static struct imxusb_platformdata ccxmx51_otg_pdata = { - .flags = MXC_EHCI_MODE_UTMI_16_BIT | MXC_EHCI_POWER_PINS_ENABLED, + .flags = MXC_EHCI_MODE_UTMI_16_BIT | MXC_EHCI_INTERNAL_PHY | + MXC_EHCI_POWER_PINS_ENABLED, .mode = IMX_USB_MODE_HOST, }; diff --git a/arch/arm/boards/ccxmx51/ccxmx51js.c b/arch/arm/boards/ccxmx51/ccxmx51js.c index 8c1d2dcd63..ae31cafedf 100644 --- a/arch/arm/boards/ccxmx51/ccxmx51js.c +++ b/arch/arm/boards/ccxmx51/ccxmx51js.c @@ -20,6 +20,8 @@ #include <init.h> #include <mci.h> #include <asm/armlinux.h> +#include <mach/gpio.h> +#include <mach/generic.h> #include <mach/imx51-regs.h> #include <mach/iomux-mx51.h> #include <mach/devices-imx51.h> @@ -27,6 +29,8 @@ #include "ccxmx51.h" +#define CCXMX51JS_USBHOST1_RESET IMX_GPIO_NR(3, 8) + static iomux_v3_cfg_t ccxmx51js_pads[] = { /* SD1 */ MX51_PAD_SD1_CLK__SD1_CLK, @@ -74,6 +78,11 @@ static struct esdhc_platform_data sdhc3_pdata = { .caps = MMC_MODE_4BIT | MMC_MODE_8BIT, }; +static struct imxusb_platformdata ccxmx51js_usbhost1_pdata = { + .flags = MXC_EHCI_MODE_ULPI | MXC_EHCI_ITC_NO_THRESHOLD, + .mode = IMX_USB_MODE_HOST, +}; + static int ccxmx51js_init(void) { mxc_iomux_v3_setup_multiple_pads(ccxmx51js_pads, ARRAY_SIZE(ccxmx51js_pads)); @@ -83,6 +92,12 @@ static int ccxmx51js_init(void) imx51_add_mmc2(&sdhc3_pdata); } + gpio_direction_output(CCXMX51JS_USBHOST1_RESET, 0); + mdelay(10); + gpio_set_value(CCXMX51JS_USBHOST1_RESET, 1); + mdelay(10); + imx51_add_usbh1(&ccxmx51js_usbhost1_pdata); + armlinux_set_architecture(ccxmx51_id->wless ? MACH_TYPE_CCWMX51JS : MACH_TYPE_CCMX51JS); return 0; diff --git a/arch/arm/boards/ccxmx51/config.h b/arch/arm/boards/ccxmx51/config.h deleted file mode 100644 index fdf2f819a1..0000000000 --- a/arch/arm/boards/ccxmx51/config.h +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @file - * @brief Global defintions for the ARM i.MX51 based ccmx51 board - * - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/chumby_falconwing/config.h b/arch/arm/boards/chumby_falconwing/config.h deleted file mode 100644 index 252aa79ae7..0000000000 --- a/arch/arm/boards/chumby_falconwing/config.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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. - * - */ - -#ifndef _CONFIG_H_ -# define _CONFIG_H_ - -#endif /* _CONFIG_H_ */ diff --git a/arch/arm/boards/chumby_falconwing/falconwing.c b/arch/arm/boards/chumby_falconwing/falconwing.c index fd5bc4c07e..720fe325d4 100644 --- a/arch/arm/boards/chumby_falconwing/falconwing.c +++ b/arch/arm/boards/chumby_falconwing/falconwing.c @@ -293,7 +293,7 @@ static int falconwing_devices_init(void) imx_set_ioclk(480000000); /* enable IOCLK to run at the PLL frequency */ /* run the SSP unit clock at 100,000 kHz */ imx_set_sspclk(0, 100000000, 1); - add_generic_device("mxs_mci", 0, NULL, IMX_SSP1_BASE, 0, + add_generic_device("mxs_mci", 0, NULL, IMX_SSP1_BASE, 0x2000, IORESOURCE_MEM, &mci_pdata); add_generic_device("stmfb", 0, NULL, IMX_FB_BASE, 4096, IORESOURCE_MEM, &fb_mode); diff --git a/arch/arm/boards/clep7212/config.h b/arch/arm/boards/clep7212/config.h deleted file mode 100644 index 6ae9a40e19..0000000000 --- a/arch/arm/boards/clep7212/config.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/crystalfontz-cfa10036/config.h b/arch/arm/boards/crystalfontz-cfa10036/config.h deleted file mode 100644 index 8f18fda7cc..0000000000 --- a/arch/arm/boards/crystalfontz-cfa10036/config.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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. - */ - -#ifndef _CONFIG_H_ -# define _CONFIG_H_ - -#endif /* _CONFIG_H_ */ diff --git a/arch/arm/boards/dmo-mx6-realq7/config.h b/arch/arm/boards/dmo-mx6-realq7/config.h deleted file mode 100644 index ca15136817..0000000000 --- a/arch/arm/boards/dmo-mx6-realq7/config.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/edb93xx/config.h b/arch/arm/boards/edb93xx/config.h deleted file mode 100644 index 6ae9a40e19..0000000000 --- a/arch/arm/boards/edb93xx/config.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/efika-mx-smartbook/config.h b/arch/arm/boards/efika-mx-smartbook/config.h deleted file mode 100644 index 143adf2552..0000000000 --- a/arch/arm/boards/efika-mx-smartbook/config.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - * 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. - * - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/eukrea_cpuimx27/config.h b/arch/arm/boards/eukrea_cpuimx27/config.h deleted file mode 100644 index e35bc042df..0000000000 --- a/arch/arm/boards/eukrea_cpuimx27/config.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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. - * - */ - -/** - * @file - * @brief Global defintions for the ARM Eukrea cpuimx27 board - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/eukrea_cpuimx51/config.h b/arch/arm/boards/eukrea_cpuimx51/config.h deleted file mode 100644 index 77d757270b..0000000000 --- a/arch/arm/boards/eukrea_cpuimx51/config.h +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @file - * @brief Global defintions for the ARM i.MX51 based cpuimx51 board - * - * 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. - * - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/eukrea_cpuimx51/eukrea_cpuimx51.c b/arch/arm/boards/eukrea_cpuimx51/eukrea_cpuimx51.c index 5e77f90322..523a805dcb 100644 --- a/arch/arm/boards/eukrea_cpuimx51/eukrea_cpuimx51.c +++ b/arch/arm/boards/eukrea_cpuimx51/eukrea_cpuimx51.c @@ -55,23 +55,23 @@ static iomux_v3_cfg_t eukrea_cpuimx51_pads[] = { MX51_PAD_UART1_RTS__UART1_RTS, MX51_PAD_UART1_CTS__UART1_CTS, /* FEC */ - MX51_PAD_DISP2_DAT1__FEC_RX_ER, + NEW_PAD_CTRL(MX51_PAD_DISP2_DAT1__FEC_RX_ER, MX51_PAD_CTRL_5), MX51_PAD_DISP2_DAT15__FEC_TDATA0, MX51_PAD_DISP2_DAT6__FEC_TDATA1, MX51_PAD_DISP2_DAT7__FEC_TDATA2, MX51_PAD_DISP2_DAT8__FEC_TDATA3, MX51_PAD_DISP2_DAT9__FEC_TX_EN, - MX51_PAD_DISP2_DAT10__FEC_COL, - MX51_PAD_DISP2_DAT11__FEC_RX_CLK, - MX51_PAD_DISP2_DAT12__FEC_RX_DV, + NEW_PAD_CTRL(MX51_PAD_DISP2_DAT10__FEC_COL, MX51_PAD_CTRL_5), + NEW_PAD_CTRL(MX51_PAD_DISP2_DAT11__FEC_RX_CLK, MX51_PAD_CTRL_5), + NEW_PAD_CTRL(MX51_PAD_DISP2_DAT12__FEC_RX_DV, MX51_PAD_CTRL_5), MX51_PAD_DISP2_DAT13__FEC_TX_CLK, MX51_PAD_DI2_PIN4__FEC_CRS, MX51_PAD_DI2_PIN2__FEC_MDC, - MX51_PAD_DI2_PIN3__FEC_MDIO, + NEW_PAD_CTRL(MX51_PAD_DI2_PIN3__FEC_MDIO, MX51_PAD_CTRL_5), MX51_PAD_DISP2_DAT14__FEC_RDATA0, MX51_PAD_DI2_DISP_CLK__FEC_RDATA1, - MX51_PAD_DI_GP4__FEC_RDATA2, - MX51_PAD_DISP2_DAT0__FEC_RDATA3, + NEW_PAD_CTRL(MX51_PAD_DI_GP4__FEC_RDATA2, MX51_PAD_CTRL_5), + NEW_PAD_CTRL(MX51_PAD_DISP2_DAT0__FEC_RDATA3, MX51_PAD_CTRL_5), MX51_PAD_DI_GP3__FEC_TX_ER, MX51_PAD_EIM_DTACK__GPIO2_31, /* LAN8700 reset pin */ /* NAND */ diff --git a/arch/arm/boards/freescale-mx23-evk/config.h b/arch/arm/boards/freescale-mx23-evk/config.h deleted file mode 100644 index 9f357bb578..0000000000 --- a/arch/arm/boards/freescale-mx23-evk/config.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * 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. - * - */ diff --git a/arch/arm/boards/freescale-mx28-evk/config.h b/arch/arm/boards/freescale-mx28-evk/config.h deleted file mode 100644 index 8f18fda7cc..0000000000 --- a/arch/arm/boards/freescale-mx28-evk/config.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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. - */ - -#ifndef _CONFIG_H_ -# define _CONFIG_H_ - -#endif /* _CONFIG_H_ */ diff --git a/arch/arm/boards/freescale-mx51-pdk/config.h b/arch/arm/boards/freescale-mx51-pdk/config.h deleted file mode 100644 index 97bfcd36c7..0000000000 --- a/arch/arm/boards/freescale-mx51-pdk/config.h +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @file - * @brief Global defintions for the ARM i.MX51 based babbage board - * - * 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. - * - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/freescale-mx53-loco/config.h b/arch/arm/boards/freescale-mx53-loco/config.h deleted file mode 100644 index 97bfcd36c7..0000000000 --- a/arch/arm/boards/freescale-mx53-loco/config.h +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @file - * @brief Global defintions for the ARM i.MX51 based babbage board - * - * 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. - * - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/freescale-mx53-smd/config.h b/arch/arm/boards/freescale-mx53-smd/config.h deleted file mode 100644 index 97bfcd36c7..0000000000 --- a/arch/arm/boards/freescale-mx53-smd/config.h +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @file - * @brief Global defintions for the ARM i.MX51 based babbage board - * - * 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. - * - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/freescale-mx6-arm2/config.h b/arch/arm/boards/freescale-mx6-arm2/config.h deleted file mode 100644 index ca15136817..0000000000 --- a/arch/arm/boards/freescale-mx6-arm2/config.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/freescale-mx6-sabrelite/config.h b/arch/arm/boards/freescale-mx6-sabrelite/config.h deleted file mode 100644 index ca15136817..0000000000 --- a/arch/arm/boards/freescale-mx6-sabrelite/config.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/freescale-mx6-sabresd/config.h b/arch/arm/boards/freescale-mx6-sabresd/config.h deleted file mode 100644 index ca15136817..0000000000 --- a/arch/arm/boards/freescale-mx6-sabresd/config.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/guf-neso/config.h b/arch/arm/boards/guf-neso/config.h deleted file mode 100644 index f8bc790125..0000000000 --- a/arch/arm/boards/guf-neso/config.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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. - * - */ - -/** - * @file - * @brief Global defintions for the ARM i.MX27 based pcm038 - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/guf-vincell/config.h b/arch/arm/boards/guf-vincell/config.h deleted file mode 100644 index b7effe5d28..0000000000 --- a/arch/arm/boards/guf-vincell/config.h +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @file - * @brief Global defintions for the ARM i.MX51 based babbage board - * - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/highbank/config.h b/arch/arm/boards/highbank/config.h deleted file mode 100644 index 25bb18f787..0000000000 --- a/arch/arm/boards/highbank/config.h +++ /dev/null @@ -1,5 +0,0 @@ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/highbank/env/boot.d/010-ahci-boot b/arch/arm/boards/highbank/env/boot.d/010-ahci-boot new file mode 120000 index 0000000000..3672f0495e --- /dev/null +++ b/arch/arm/boards/highbank/env/boot.d/010-ahci-boot @@ -0,0 +1 @@ +../boot/ahci-boot
\ No newline at end of file diff --git a/arch/arm/boards/highbank/env/boot.d/011-ahci b/arch/arm/boards/highbank/env/boot.d/011-ahci new file mode 120000 index 0000000000..36b3b2815b --- /dev/null +++ b/arch/arm/boards/highbank/env/boot.d/011-ahci @@ -0,0 +1 @@ +../boot/ahci
\ No newline at end of file diff --git a/arch/arm/boards/highbank/env/boot.d/020-mmc-boot b/arch/arm/boards/highbank/env/boot.d/020-mmc-boot new file mode 120000 index 0000000000..85c19bbd66 --- /dev/null +++ b/arch/arm/boards/highbank/env/boot.d/020-mmc-boot @@ -0,0 +1 @@ +../boot/mmc-boot
\ No newline at end of file diff --git a/arch/arm/boards/highbank/env/boot.d/021-mmc b/arch/arm/boards/highbank/env/boot.d/021-mmc new file mode 120000 index 0000000000..5af95d0ac7 --- /dev/null +++ b/arch/arm/boards/highbank/env/boot.d/021-mmc @@ -0,0 +1 @@ +../boot/mmc
\ No newline at end of file diff --git a/arch/arm/boards/highbank/env/boot.d/030-net b/arch/arm/boards/highbank/env/boot.d/030-net new file mode 120000 index 0000000000..70b8ea3965 --- /dev/null +++ b/arch/arm/boards/highbank/env/boot.d/030-net @@ -0,0 +1 @@ +../boot/net
\ No newline at end of file diff --git a/arch/arm/boards/highbank/env/boot.d/031-net-eth1 b/arch/arm/boards/highbank/env/boot.d/031-net-eth1 new file mode 120000 index 0000000000..5a30a308c7 --- /dev/null +++ b/arch/arm/boards/highbank/env/boot.d/031-net-eth1 @@ -0,0 +1 @@ +../boot/net-eth1
\ No newline at end of file diff --git a/arch/arm/boards/highbank/env/boot/ahci b/arch/arm/boards/highbank/env/boot/ahci new file mode 100644 index 0000000000..3bdb809932 --- /dev/null +++ b/arch/arm/boards/highbank/env/boot/ahci @@ -0,0 +1,21 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + boot-menu-add-entry "$0" "AHCI" + exit +fi + +path="/mnt/ahci" + +global.bootm.image="${path}/zImage" + +. /env/data/oftree + +oftree=${path}/oftree +if [ -f $oftree ]; then + global.bootm.oftree="$oftree" +fi + +# The rootdevice may actually be mmcblk1p2 if a card +# is inserted to the back MMC slot +global.linux.bootargs.dyn.root="root=/dev/sda2" diff --git a/arch/arm/boards/highbank/env/boot/ahci-boot b/arch/arm/boards/highbank/env/boot/ahci-boot new file mode 100644 index 0000000000..0064a46fcc --- /dev/null +++ b/arch/arm/boards/highbank/env/boot/ahci-boot @@ -0,0 +1,21 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + boot-menu-add-entry "$0" "AHCI (UEFI boot partiton)" + exit +fi + +path="/mnt/ahci-boot" + +global.bootm.image="${path}/zImage" + +. /env/data/oftree + +oftree=${path}/oftree +if [ -f $oftree ]; then + global.bootm.oftree="$oftree" +fi + +# The rootdevice may actually be mmcblk1p2 if a card +# is inserted to the back MMC slot +global.linux.bootargs.dyn.root="root=/dev/sda2" diff --git a/arch/arm/boards/highbank/env/boot/mmc b/arch/arm/boards/highbank/env/boot/mmc new file mode 100644 index 0000000000..43a04b5d6b --- /dev/null +++ b/arch/arm/boards/highbank/env/boot/mmc @@ -0,0 +1,21 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + boot-menu-add-entry "$0" "MMC slot" + exit +fi + +path="/mnt/mmc" + +global.bootm.image="${path}/zimage" + +. /env/data/oftree + +oftree=${path}/oftree +if [ -f $oftree ]; then + global.bootm.oftree="$oftree" +fi + +# The rootdevice may actually be mmcblk1p2 if a card +# is inserted to the back MMC slot +global.linux.bootargs.dyn.root="root=/dev/mmcblk0p2" diff --git a/arch/arm/boards/highbank/env/boot/mmc-boot b/arch/arm/boards/highbank/env/boot/mmc-boot new file mode 100644 index 0000000000..93cd99b684 --- /dev/null +++ b/arch/arm/boards/highbank/env/boot/mmc-boot @@ -0,0 +1,21 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + boot-menu-add-entry "$0" "MMC slot (UEFI boot partiton)" + exit +fi + +path="/mnt/mmc-boot" + +global.bootm.image="${path}/zimage" + +. /env/data/oftree + +oftree=${path}/oftree +if [ -f $oftree ]; then + global.bootm.oftree="$oftree" +fi + +# The rootdevice may actually be mmcblk1p2 if a card +# is inserted to the back MMC slot +global.linux.bootargs.dyn.root="root=/dev/mmcblk0p2" diff --git a/arch/arm/boards/highbank/env/boot/net b/arch/arm/boards/highbank/env/boot/net new file mode 100644 index 0000000000..80862cdac1 --- /dev/null +++ b/arch/arm/boards/highbank/env/boot/net @@ -0,0 +1,18 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + boot-menu-add-entry "$0" "network (tftp, nfs) (eth0)" + exit +fi + +ethact eth0 + +path="/mnt/tftp" + +. /env/data/oftree + +global.bootm.image="${path}/${global.user}-linux-${global.hostname}" +#global.bootm.oftree="${path}/${global.user}-oftree-${global.hostname}" +nfsroot="/home/${global.user}/nfsroot/${global.hostname}" +bootargs-ip +global.linux.bootargs.dyn.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp" diff --git a/arch/arm/boards/highbank/env/boot/net-eth1 b/arch/arm/boards/highbank/env/boot/net-eth1 new file mode 100644 index 0000000000..d9e9804a02 --- /dev/null +++ b/arch/arm/boards/highbank/env/boot/net-eth1 @@ -0,0 +1,18 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + boot-menu-add-entry "$0" "network (tftp, nfs) (eth1)" + exit +fi + +ethact eth1 + +path="/mnt/tftp" + +. /env/data/oftree + +global.bootm.image="${path}/${global.user}-linux-${global.hostname}" +#global.bootm.oftree="${path}/${global.user}-oftree-${global.hostname}" +nfsroot="/home/${global.user}/nfsroot/${global.hostname}" +bootargs-ip +global.linux.bootargs.dyn.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp" diff --git a/arch/arm/boards/highbank/env/config b/arch/arm/boards/highbank/env/config deleted file mode 100644 index 1bb2c493b2..0000000000 --- a/arch/arm/boards/highbank/env/config +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -# use 'dhcp' to do dhcp in barebox and in kernel -# use 'none' if you want to skip kernel ip autoconfiguration -ip=dhcp -global.dhcp.vendor_id=barebox-highbank - -# or set your networking parameters here -#eth0.ipaddr=a.b.c.d -#eth0.netmask=a.b.c.d -#eth0.gateway=a.b.c.d -#eth0.serverip=a.b.c.d - -# can be either 'nfs', 'tftp' or 'nor' -kernel_loc=tftp -# can be either 'net', 'nor' or 'initrd' -rootfs_loc=initrd - -# can be either 'jffs2' or 'ubifs' -rootfs_type=ubifs -rootfsimage=root.$rootfs_type - -kernelimage=zImage -#kernelimage=uImage -#kernelimage=Image -#kernelimage=Image.lzo - -autoboot_timeout=3 - -bootargs="console=ttyAMA0,115200n8 CONSOLE=/dev/ttyAMA0" - -# set a fancy prompt (if support is compiled in) -PS1="\e[1;31m[barebox@\h]:\w\e[0m\n# " diff --git a/arch/arm/boards/highbank/env/config-board b/arch/arm/boards/highbank/env/config-board new file mode 100644 index 0000000000..a64d9e3245 --- /dev/null +++ b/arch/arm/boards/highbank/env/config-board @@ -0,0 +1,11 @@ +#!/bin/sh + +# board defaults, do not change in running system. Change /env/config +# instead + +global.hostname=highbank +global.allow_color=true +global.autoboot_timeout=3 +global.bootm.oftree="/dev/dtb" +global.linux.bootargs.base="console=ttyAMA0,115200n8 CONSOLE=/dev/ttyAMA0" +global.boot.default=/env/boot.d diff --git a/arch/arm/boards/highbank/env/data/oftree b/arch/arm/boards/highbank/env/data/oftree new file mode 100644 index 0000000000..9a94b310c3 --- /dev/null +++ b/arch/arm/boards/highbank/env/data/oftree @@ -0,0 +1,4 @@ +#!/bin/sh + +#device tree provided by the firmware +global.bootm.oftree="/dev/dtb" diff --git a/arch/arm/boards/highbank/env/bin/init_board b/arch/arm/boards/highbank/env/init/001-dtb-probe index 610db1500e..610db1500e 100644 --- a/arch/arm/boards/highbank/env/bin/init_board +++ b/arch/arm/boards/highbank/env/init/001-dtb-probe diff --git a/arch/arm/boards/highbank/env/init/automount b/arch/arm/boards/highbank/env/init/automount new file mode 100644 index 0000000000..2c283c6eed --- /dev/null +++ b/arch/arm/boards/highbank/env/init/automount @@ -0,0 +1,27 @@ +#!/bin/sh + +if [ "$1" = menu ]; then + init-menu-add-entry "$0" "Automountpoints" + exit +fi + +# automount tftp server based on $eth0.serverip + +mkdir -p /mnt/tftp +automount /mnt/tftp 'ifup eth0 && mount -t tftp $eth0.serverip /mnt/tftp' + +# SD card slot, boot partition +mkdir -p /mnt/mmc-boot +automount -d /mnt/mmc 'mount /dev/disk0.boot /mnt/mmc-boot' + +# SD card slot, first partition +mkdir -p /mnt/mmc +automount -d /mnt/mmc 'mount /dev/disk0.0 /mnt/mmc' + +# AHCI, boot partition +mkdir -p /mnt/ahci-boot +automount -d /mnt/ahci 'mount /dev/ata0.boot /mnt/ahci-boot' + +# AHCI, first partition +mkdir -p /mnt/ahci +automount -d /mnt/ahci 'mount /dev/ata0.0 /mnt/ahci' diff --git a/arch/arm/boards/highbank/env/init/ps1 b/arch/arm/boards/highbank/env/init/ps1 new file mode 100644 index 0000000000..a94acc14f8 --- /dev/null +++ b/arch/arm/boards/highbank/env/init/ps1 @@ -0,0 +1,9 @@ +#!/bin/sh + +/env/config + +if [ ${global.allow_color} = "true" ]; then + export PS1="\e[1;32mbarebox@\e[1;36m\h:\w\e[0m\n# " +else + export PS1="barebox@\h:\w\n# " +fi diff --git a/arch/arm/boards/imx21ads/config.h b/arch/arm/boards/imx21ads/config.h deleted file mode 100644 index d5ee8f85ec..0000000000 --- a/arch/arm/boards/imx21ads/config.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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. - * - */ - -/** - * @file - * @brief Global defintions for the ARM i.MX21 based imx21ads - **/ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/imx233-olinuxino/config.h b/arch/arm/boards/imx233-olinuxino/config.h deleted file mode 100644 index 87d9e2f476..0000000000 --- a/arch/arm/boards/imx233-olinuxino/config.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ - -#ifndef _CONFIG_H_ -# define _CONFIG_H_ - -#endif /* _CONFIG_H_ */ diff --git a/arch/arm/boards/imx27ads/config.h b/arch/arm/boards/imx27ads/config.h deleted file mode 100644 index eb406f00ee..0000000000 --- a/arch/arm/boards/imx27ads/config.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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. - * - */ - -/** - * @file - * @brief Global defintions for the Freescale imx27ads ARM board - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/karo-tx28/config.h b/arch/arm/boards/karo-tx28/config.h deleted file mode 100644 index 8f18fda7cc..0000000000 --- a/arch/arm/boards/karo-tx28/config.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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. - */ - -#ifndef _CONFIG_H_ -# define _CONFIG_H_ - -#endif /* _CONFIG_H_ */ diff --git a/arch/arm/boards/karo-tx51/config.h b/arch/arm/boards/karo-tx51/config.h deleted file mode 100644 index 143adf2552..0000000000 --- a/arch/arm/boards/karo-tx51/config.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - * 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. - * - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/karo-tx53/config.h b/arch/arm/boards/karo-tx53/config.h deleted file mode 100644 index b7effe5d28..0000000000 --- a/arch/arm/boards/karo-tx53/config.h +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @file - * @brief Global defintions for the ARM i.MX51 based babbage board - * - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/mioa701/config.h b/arch/arm/boards/mioa701/config.h deleted file mode 100644 index 390aa30ebf..0000000000 --- a/arch/arm/boards/mioa701/config.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * (C) 2011 Robert Jarzmik <robert.jarzmik@free.fr> - * - * See file CREDITS for list of people who contributed to this - * project. - * - * 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. - * - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/netx/config.h b/arch/arm/boards/netx/config.h deleted file mode 100644 index ca15136817..0000000000 --- a/arch/arm/boards/netx/config.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/nhk8815/config.h b/arch/arm/boards/nhk8815/config.h deleted file mode 100644 index da84fa5f6b..0000000000 --- a/arch/arm/boards/nhk8815/config.h +++ /dev/null @@ -1 +0,0 @@ -/* nothing */ diff --git a/arch/arm/boards/omap343xdsp/config.h b/arch/arm/boards/omap343xdsp/config.h deleted file mode 100644 index 143adf2552..0000000000 --- a/arch/arm/boards/omap343xdsp/config.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - * 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. - * - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/omap3evm/config.h b/arch/arm/boards/omap3evm/config.h deleted file mode 100644 index 143adf2552..0000000000 --- a/arch/arm/boards/omap3evm/config.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - * 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. - * - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/panda/config.h b/arch/arm/boards/panda/config.h deleted file mode 100644 index da84fa5f6b..0000000000 --- a/arch/arm/boards/panda/config.h +++ /dev/null @@ -1 +0,0 @@ -/* nothing */ diff --git a/arch/arm/boards/pcm038/config.h b/arch/arm/boards/pcm038/config.h deleted file mode 100644 index f8bc790125..0000000000 --- a/arch/arm/boards/pcm038/config.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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. - * - */ - -/** - * @file - * @brief Global defintions for the ARM i.MX27 based pcm038 - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/pcm038/pcm038.c b/arch/arm/boards/pcm038/pcm038.c index df8b1f949c..4b2fa6c6ca 100644 --- a/arch/arm/boards/pcm038/pcm038.c +++ b/arch/arm/boards/pcm038/pcm038.c @@ -46,12 +46,15 @@ #include "pll.h" +#define PCM038_GPIO_FEC_RST (GPIO_PORTC + 30) +#define PCM038_GPIO_SPI_CS0 (GPIO_PORTD + 28) + static struct fec_platform_data fec_info = { .xcv_type = PHY_INTERFACE_MODE_MII, .phy_addr = 1, }; -static int pcm038_spi_cs[] = {GPIO_PORTD + 28}; +static int pcm038_spi_cs[] = { PCM038_GPIO_SPI_CS0 }; static struct spi_imx_master pcm038_spi_0_data = { .chipselect = pcm038_spi_cs, @@ -191,6 +194,7 @@ static int pcm038_devices_init(void) long sram_size; unsigned int mode[] = { + /* FEC */ PD0_AIN_FEC_TXD0, PD1_AIN_FEC_TXD1, PD2_AIN_FEC_TXD2, @@ -209,16 +213,19 @@ static int pcm038_devices_init(void) PD15_AOUT_FEC_COL, PD16_AIN_FEC_TX_ER, PF23_AIN_FEC_TX_EN, + PCM038_GPIO_FEC_RST | GPIO_GPIO | GPIO_OUT, + /* UART1 */ PE12_PF_UART1_TXD, PE13_PF_UART1_RXD, PE14_PF_UART1_CTS, PE15_PF_UART1_RTS, + /* CSPI1 */ PD25_PF_CSPI1_RDY, - GPIO_PORTD | 28 | GPIO_GPIO | GPIO_OUT, + PCM038_GPIO_SPI_CS0 | GPIO_GPIO | GPIO_OUT, PD29_PF_CSPI1_SCLK, PD30_PF_CSPI1_MISO, PD31_PF_CSPI1_MOSI, - /* display */ + /* Display */ PA5_PF_LSCLK, PA6_PF_LD0, PA7_PF_LD1, @@ -298,6 +305,7 @@ static int pcm038_devices_init(void) /* Register the fec device after the PLL re-initialisation * as the fec depends on the (now higher) ipg clock */ + gpio_set_value(PCM038_GPIO_FEC_RST, 1); imx27_add_fec(&fec_info); switch (bootsource_get()) { diff --git a/arch/arm/boards/pcm049/config.h b/arch/arm/boards/pcm049/config.h deleted file mode 100644 index da84fa5f6b..0000000000 --- a/arch/arm/boards/pcm049/config.h +++ /dev/null @@ -1 +0,0 @@ -/* nothing */ diff --git a/arch/arm/boards/pcm051/config.h b/arch/arm/boards/pcm051/config.h deleted file mode 100644 index 8b2b87642e..0000000000 --- a/arch/arm/boards/pcm051/config.h +++ /dev/null @@ -1,21 +0,0 @@ -/** - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/phycard-a-l1/config.h b/arch/arm/boards/phycard-a-l1/config.h deleted file mode 100644 index 85ceff9b2a..0000000000 --- a/arch/arm/boards/phycard-a-l1/config.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * (C) Copyright 2011 Jurgen Kilb <j.kilb@phytec.de> - * - * 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. - * - */ -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/phycard-a-xl2/config.h b/arch/arm/boards/phycard-a-xl2/config.h deleted file mode 100644 index da84fa5f6b..0000000000 --- a/arch/arm/boards/phycard-a-xl2/config.h +++ /dev/null @@ -1 +0,0 @@ -/* nothing */ diff --git a/arch/arm/boards/phycard-i.MX27/config.h b/arch/arm/boards/phycard-i.MX27/config.h deleted file mode 100644 index f8bc790125..0000000000 --- a/arch/arm/boards/phycard-i.MX27/config.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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. - * - */ - -/** - * @file - * @brief Global defintions for the ARM i.MX27 based pcm038 - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/raspberry-pi/config.h b/arch/arm/boards/raspberry-pi/config.h deleted file mode 100644 index ca15136817..0000000000 --- a/arch/arm/boards/raspberry-pi/config.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/sama5d3xek/hw_version.c b/arch/arm/boards/sama5d3xek/hw_version.c index 79fd63a349..450eb9f8a1 100644 --- a/arch/arm/boards/sama5d3xek/hw_version.c +++ b/arch/arm/boards/sama5d3xek/hw_version.c @@ -226,10 +226,8 @@ static void at91sama5d3xek_devices_detect_one(const char *name) dev_add_param_fixed(dev, "board", bname); sprintf(str, "%.2s", info.vendor_country); dev_add_param_fixed(dev, "country", str); - sprintf(str, "%d", info.year); - dev_add_param_fixed(dev, "year", str); - sprintf(str, "%d", info.week); - dev_add_param_fixed(dev, "week", str); + dev_add_param_int_ro(dev, "year", info.year, "%d"); + dev_add_param_int_ro(dev, "week", info.week, "%d"); sprintf(str, "%c", info.revision_board); dev_add_param_fixed(dev, "revision_board", str); sprintf(str, "%c", info.revision_schema); diff --git a/arch/arm/boards/toshiba-ac100/config.h b/arch/arm/boards/toshiba-ac100/config.h deleted file mode 100644 index 25bb18f787..0000000000 --- a/arch/arm/boards/toshiba-ac100/config.h +++ /dev/null @@ -1,5 +0,0 @@ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/tqma53/config.h b/arch/arm/boards/tqma53/config.h deleted file mode 100644 index ca15136817..0000000000 --- a/arch/arm/boards/tqma53/config.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/versatile/config.h b/arch/arm/boards/versatile/config.h deleted file mode 100644 index 25bb18f787..0000000000 --- a/arch/arm/boards/versatile/config.h +++ /dev/null @@ -1,5 +0,0 @@ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/boards/vexpress/config.h b/arch/arm/boards/vexpress/config.h deleted file mode 100644 index 25bb18f787..0000000000 --- a/arch/arm/boards/vexpress/config.h +++ /dev/null @@ -1,5 +0,0 @@ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/arm/configs/at91sam9m10g45ek_defconfig b/arch/arm/configs/at91sam9m10g45ek_defconfig index 1df34f7511..7e05e95760 100644 --- a/arch/arm/configs/at91sam9m10g45ek_defconfig +++ b/arch/arm/configs/at91sam9m10g45ek_defconfig @@ -64,8 +64,10 @@ CONFIG_NET_RESOLV=y CONFIG_DRIVER_NET_MACB=y CONFIG_NET_USB=y CONFIG_NET_USB_ASIX=y -# CONFIG_SPI is not set +CONFIG_DRIVER_SPI_ATMEL=y CONFIG_MTD=y +# CONFIG_MTD_OOB_DEVICE is not set +CONFIG_MTD_DATAFLASH=y CONFIG_NAND=y # CONFIG_NAND_ECC_HW is not set # CONFIG_NAND_ECC_HW_SYNDROME is not set diff --git a/arch/arm/configs/phycard_a_l1_defconfig b/arch/arm/configs/phycard_a_l1_defconfig index d90a333e0a..fabaa2d688 100644 --- a/arch/arm/configs/phycard_a_l1_defconfig +++ b/arch/arm/configs/phycard_a_l1_defconfig @@ -7,7 +7,6 @@ CONFIG_CPU_V7=y CONFIG_CPU_32v7=y CONFIG_BOARDINFO="Phytec phyCARD-A-L1" CONFIG_ARCH_OMAP3=y -CONFIG_OMAP_CLOCK_ALL=y CONFIG_OMAP_CLOCK_SOURCE_S32K=y CONFIG_OMAP3_CLOCK_CONFIG=y CONFIG_OMAP3_COPY_CLOCK_SRAM=n diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c index 34fe5c3515..e3ea3b6b9e 100644 --- a/arch/arm/cpu/mmu.c +++ b/arch/arm/cpu/mmu.c @@ -189,7 +189,7 @@ static int arm_mmu_remap_sdram(struct memory_bank *bank) ptes, ttb_start, ttb_end); for (i = 0; i < num_ptes; i++) { - ptes[i] = (phys + i * 4096) | PTE_TYPE_SMALL | + ptes[i] = (phys + i * PAGE_SIZE) | PTE_TYPE_SMALL | pte_flags_cached; } @@ -300,7 +300,7 @@ static int mmu_init(void) asm volatile ("mcr p15,0,%0,c3,c0,0" : : "r"(i) /*:*/); /* create a flat mapping using 1MiB sections */ - create_sections(0, 0, 4096, PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | + create_sections(0, 0, PAGE_SIZE, PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | PMD_TYPE_SECT); vectors_init(); @@ -332,7 +332,7 @@ void *dma_alloc_coherent(size_t size) void *ret; size = PAGE_ALIGN(size); - ret = xmemalign(4096, size); + ret = xmemalign(PAGE_SIZE, size); dma_inv_range((unsigned long)ret, (unsigned long)ret + size); @@ -353,6 +353,7 @@ void *phys_to_virt(unsigned long phys) void dma_free_coherent(void *mem, size_t size) { + size = PAGE_ALIGN(size); remap_range(mem, size, pte_flags_cached); free(mem); diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c index c2618c7b56..0e39a526d2 100644 --- a/arch/arm/mach-at91/gpio.c +++ b/arch/arm/mach-at91/gpio.c @@ -185,10 +185,10 @@ static struct at91_pinctrl_mux_ops at91sam9x5_ops = { int at91_mux_pin(unsigned pin, enum at91_mux mux, int use_pullup) { struct at91_gpio_chip *at91_gpio = pin_to_controller(pin); - void __iomem *pio = at91_gpio->regbase; + void __iomem *pio; + struct device_d *dev; unsigned mask = pin_to_mask(pin); int bank = pin_to_bank(pin); - struct device_d *dev = at91_gpio->chip.dev; if (!at91_gpio) return -EINVAL; @@ -197,6 +197,7 @@ int at91_mux_pin(unsigned pin, enum at91_mux mux, int use_pullup) if (!pio) return -EINVAL; + dev = at91_gpio->chip.dev; at91_mux_disable_interrupt(pio, mask); pin %= MAX_NB_GPIO_PER_BANK; diff --git a/arch/arm/mach-at91/sam9_smc.c b/arch/arm/mach-at91/sam9_smc.c index b48275e07e..a137da4266 100644 --- a/arch/arm/mach-at91/sam9_smc.c +++ b/arch/arm/mach-at91/sam9_smc.c @@ -120,12 +120,12 @@ void sam9_smc_read(int id, int cs, struct sam9_smc_config *config) static int at91sam9_smc_probe(struct device_d *dev) { - int id; + int id = dev->id; - if (dev->id < 0) { + if (id < 0) { id = 0; - } else if (dev->id > 1) { - dev_warn(dev, ": id > 2\n"); + } else if (id > 1) { + dev_warn(dev, "id > 1\n"); return -EIO; } diff --git a/arch/arm/mach-highbank/Kconfig b/arch/arm/mach-highbank/Kconfig index 47c6405eb1..9cfe53968b 100644 --- a/arch/arm/mach-highbank/Kconfig +++ b/arch/arm/mach-highbank/Kconfig @@ -12,6 +12,7 @@ choice config MACH_HIGHBANK bool "Calxeda Highbank" + select HAVE_DEFAULT_ENVIRONMENT_NEW endchoice diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig index 8ddec9d605..359b5cd091 100644 --- a/arch/arm/mach-imx/Kconfig +++ b/arch/arm/mach-imx/Kconfig @@ -17,9 +17,9 @@ config ARCH_TEXT_BASE default 0x87f00000 if MACH_PCM043 default 0x08f80000 if MACH_SCB9328 default 0xa7e00000 if MACH_NESO - default 0x97f00000 if MACH_MX51_PDK - default 0x7ff00000 if MACH_MX53_LOCO - default 0x7ff00000 if MACH_MX53_SMD + default 0x97f00000 if MACH_FREESCALE_MX51_PDK + default 0x7ff00000 if MACH_FREESCALE_MX53_LOCO + default 0x7ff00000 if MACH_FREESCALE_MX53_SMD default 0x87f00000 if MACH_GUF_CUPID default 0x93d00000 if MACH_TX25 default 0x7ff00000 if MACH_TQMA53 @@ -165,44 +165,53 @@ choice config ARCH_IMX1 bool "i.MX1" select CPU_ARM920T + select PINCTRL_IMX_IOMUX_V1 config ARCH_IMX21 bool "i.MX21" select CPU_ARM926T + select PINCTRL_IMX_IOMUX_V1 config ARCH_IMX25 bool "i.MX25" select CPU_ARM926T select ARCH_HAS_FEC_IMX + select PINCTRL_IMX_IOMUX_V3 config ARCH_IMX27 bool "i.MX27" select CPU_ARM926T select ARCH_HAS_FEC_IMX + select PINCTRL_IMX_IOMUX_V1 config ARCH_IMX31 select CPU_V6 bool "i.MX31" + select PINCTRL_IMX_IOMUX_V2 config ARCH_IMX35 bool "i.MX35" select CPU_V6 select ARCH_HAS_FEC_IMX + select PINCTRL_IMX_IOMUX_V3 config ARCH_IMX51 bool "i.MX51" select CPU_V7 select ARCH_HAS_FEC_IMX + select PINCTRL_IMX_IOMUX_V3 config ARCH_IMX53 bool "i.MX53" select CPU_V7 select ARCH_HAS_FEC_IMX + select PINCTRL_IMX_IOMUX_V3 config ARCH_IMX6 bool "i.MX6" select ARCH_HAS_FEC_IMX select CPU_V7 + select PINCTRL_IMX_IOMUX_V3 endchoice diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile index ff8f15b8c0..72125e775b 100644 --- a/arch/arm/mach-imx/Makefile +++ b/arch/arm/mach-imx/Makefile @@ -1,14 +1,14 @@ -obj-y += clocksource.o gpio.o -obj-$(CONFIG_ARCH_IMX1) += imx1.o iomux-v1.o clk-imx1.o -obj-$(CONFIG_ARCH_IMX25) += imx25.o iomux-v3.o clk-imx25.o -obj-$(CONFIG_ARCH_IMX21) += imx21.o iomux-v1.o clk-imx21.o -obj-$(CONFIG_ARCH_IMX27) += imx27.o iomux-v1.o clk-imx27.o -obj-$(CONFIG_ARCH_IMX31) += imx31.o iomux-v2.o clk-imx31.o -obj-$(CONFIG_ARCH_IMX35) += imx35.o iomux-v3.o clk-imx35.o -obj-$(CONFIG_ARCH_IMX51) += imx51.o iomux-v3.o imx5.o clk-imx5.o -obj-$(CONFIG_ARCH_IMX53) += imx53.o iomux-v3.o imx5.o clk-imx5.o esdctl-v4.o +obj-y += clocksource.o +obj-$(CONFIG_ARCH_IMX1) += imx1.o clk-imx1.o +obj-$(CONFIG_ARCH_IMX25) += imx25.o clk-imx25.o +obj-$(CONFIG_ARCH_IMX21) += imx21.o clk-imx21.o +obj-$(CONFIG_ARCH_IMX27) += imx27.o clk-imx27.o +obj-$(CONFIG_ARCH_IMX31) += imx31.o clk-imx31.o +obj-$(CONFIG_ARCH_IMX35) += imx35.o clk-imx35.o +obj-$(CONFIG_ARCH_IMX51) += imx51.o imx5.o clk-imx5.o +obj-$(CONFIG_ARCH_IMX53) += imx53.o imx5.o clk-imx5.o esdctl-v4.o pbl-$(CONFIG_ARCH_IMX53) += imx53.o imx5.o esdctl-v4.o -obj-$(CONFIG_ARCH_IMX6) += imx6.o iomux-v3.o usb-imx6.o clk-imx6.o +obj-$(CONFIG_ARCH_IMX6) += imx6.o usb-imx6.o clk-imx6.o lwl-$(CONFIG_ARCH_IMX6) += imx6-mmdc.o obj-$(CONFIG_IMX_IIM) += iim.o obj-$(CONFIG_NAND_IMX) += nand.o diff --git a/arch/arm/mach-imx/iim.c b/arch/arm/mach-imx/iim.c index 69ddc4d6a8..ce2bbafc90 100644 --- a/arch/arm/mach-imx/iim.c +++ b/arch/arm/mach-imx/iim.c @@ -33,6 +33,9 @@ static unsigned long mac_addr_base; +static int iim_write_enable; +static int iim_sense_enable; + struct iim_priv { struct cdev cdev; void __iomem *base; @@ -88,14 +91,9 @@ static ssize_t imx_iim_cdev_read(struct cdev *cdev, void *buf, size_t count, { ulong size, i; struct iim_priv *priv = cdev->priv; - const char *sense_param; - unsigned long explicit_sense = 0; - - if ((sense_param = dev_get_param(cdev->dev, "explicit_sense_enable"))) - explicit_sense = simple_strtoul(sense_param, NULL, 0); size = min((loff_t)count, priv->banksize - offset); - if (explicit_sense) { + if (iim_sense_enable) { for (i = 0; i < size; i++) { int row_val; @@ -113,7 +111,6 @@ static ssize_t imx_iim_cdev_read(struct cdev *cdev, void *buf, size_t count, return size; } -#ifdef CONFIG_IMX_IIM_FUSE_BLOW static int do_fuse_blow(void __iomem *reg_base, unsigned int bank, unsigned int row, u8 value) { @@ -173,22 +170,16 @@ out: writeb(0, reg_base + IIM_PREG_P); return ret; } -#endif /* CONFIG_IMX_IIM_FUSE_BLOW */ static ssize_t imx_iim_cdev_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags) { ulong size, i; struct iim_priv *priv = cdev->priv; - const char *write_param; - unsigned int blow_enable = 0; - - if ((write_param = dev_get_param(cdev->dev, "permanent_write_enable"))) - blow_enable = simple_strtoul(write_param, NULL, 0); size = min((loff_t)count, priv->banksize - offset); -#ifdef CONFIG_IMX_IIM_FUSE_BLOW - if (blow_enable) { + + if (IS_ENABLED(CONFIG_IMX_IIM_FUSE_BLOW) && iim_write_enable) { for (i = 0; i < size; i++) { int ret; @@ -197,9 +188,7 @@ static ssize_t imx_iim_cdev_write(struct cdev *cdev, const void *buf, size_t cou if (ret < 0) return ret; } - } else -#endif /* CONFIG_IMX_IIM_FUSE_BLOW */ - { + } else { for (i = 0; i < size; i++) ((u8 *)priv->bankbase)[(offset+i)*4] = ((u8 *)buf)[i]; } @@ -213,21 +202,6 @@ static struct file_operations imx_iim_ops = { .lseek = dev_lseek_default, }; -static int imx_iim_blow_enable_set(struct device_d *dev, struct param_d *param, - const char *val) -{ - unsigned long blow_enable; - - if (val == NULL) - return -EINVAL; - - blow_enable = simple_strtoul(val, NULL, 0); - if (blow_enable > 1) - return -EINVAL; - - return dev_param_set_generic(dev, param, blow_enable ? "1" : "0"); -} - static int imx_iim_add_bank(struct device_d *dev, void __iomem *base, int num) { struct iim_priv *priv; @@ -254,7 +228,6 @@ static int imx_iim_add_bank(struct device_d *dev, void __iomem *base, int num) static int imx_iim_probe(struct device_d *dev) { struct imx_iim_platform_data *pdata = dev->platform_data; - int err; int i; void __iomem *base; @@ -267,23 +240,13 @@ static int imx_iim_probe(struct device_d *dev) imx_iim_add_bank(dev, base, i); } -#ifdef CONFIG_IMX_IIM_FUSE_BLOW - err = dev_add_param(dev, "permanent_write_enable", - imx_iim_blow_enable_set, NULL, 0); - if (err < 0) - return err; - err = dev_set_param(dev, "permanent_write_enable", "0"); - if (err < 0) - return err; -#endif /* CONFIG_IMX_IIM_FUSE_BLOW */ - - err = dev_add_param(dev, "explicit_sense_enable", - imx_iim_blow_enable_set, NULL, 0); - if (err < 0) - return err; - err = dev_set_param(dev, "explicit_sense_enable", "1"); - if (err < 0) - return err; + + if (IS_ENABLED(CONFIG_IMX_IIM_FUSE_BLOW)) + dev_add_param_bool(dev, "permanent_write_enable", + NULL, NULL, &iim_write_enable, NULL); + + dev_add_param_bool(dev, "explicit_sense_enable", + NULL, NULL, &iim_sense_enable, NULL); return 0; } diff --git a/arch/arm/mach-imx/include/mach/iomux-mx27.h b/arch/arm/mach-imx/include/mach/iomux-mx27.h index 7d2496708e..b6e334559d 100644 --- a/arch/arm/mach-imx/include/mach/iomux-mx27.h +++ b/arch/arm/mach-imx/include/mach/iomux-mx27.h @@ -25,12 +25,6 @@ #define PA2_PF_USBH2_DATA7 (GPIO_PORTA | GPIO_PF | 2) #define PA3_PF_USBH2_NXT (GPIO_PORTA | GPIO_PF | 3) #define PA4_PF_USBH2_STP (GPIO_PORTA | GPIO_PF | 4) -#define PB4_PF_SD2_D0 (GPIO_PORTB | GPIO_PF | 4) -#define PB5_PF_SD2_D1 (GPIO_PORTB | GPIO_PF | 5) -#define PB6_PF_SD2_D2 (GPIO_PORTB | GPIO_PF | 6) -#define PB7_PF_SD2_D3 (GPIO_PORTB | GPIO_PF | 7) -#define PB8_PF_SD2_CMD (GPIO_PORTB | GPIO_PF | 8) -#define PB9_PF_SD2_CLK (GPIO_PORTB | GPIO_PF | 9) #define PB22_PF_USBH1_SUSP (GPIO_PORTB | GPIO_PF | 22) #define PB25_PF_USBH1_RCV (GPIO_PORTB | GPIO_PF | 25) #define PC5_PF_I2C2_SDA (GPIO_PORTC | GPIO_PF | GPIO_IN | 5) diff --git a/arch/arm/mach-imx/include/mach/iomux-mx2x.h b/arch/arm/mach-imx/include/mach/iomux-mx2x.h index 2f9560fa71..15c2e2b060 100644 --- a/arch/arm/mach-imx/include/mach/iomux-mx2x.h +++ b/arch/arm/mach-imx/include/mach/iomux-mx2x.h @@ -86,12 +86,12 @@ #define PC31_PF_SSI3_CLK (GPIO_PORTC | GPIO_PF | GPIO_IN | 31) #define PD17_PF_I2C_DATA (GPIO_PORTD | GPIO_PF | GPIO_OUT | 17) #define PD18_PF_I2C_CLK (GPIO_PORTD | GPIO_PF | GPIO_OUT | 18) -#define PD19_PF_CSPI2_SS2 (GPIO_PORTD | GPIO_PF | 19) -#define PD20_PF_CSPI2_SS1 (GPIO_PORTD | GPIO_PF | 20) -#define PD21_PF_CSPI2_SS0 (GPIO_PORTD | GPIO_PF | 21) -#define PD22_PF_CSPI2_SCLK (GPIO_PORTD | GPIO_PF | 22) -#define PD23_PF_CSPI2_MISO (GPIO_PORTD | GPIO_PF | 23) -#define PD24_PF_CSPI2_MOSI (GPIO_PORTD | GPIO_PF | 24) +#define PD19_PF_CSPI2_SS2 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 19) +#define PD20_PF_CSPI2_SS1 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 20) +#define PD21_PF_CSPI2_SS0 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 21) +#define PD22_PF_CSPI2_SCLK (GPIO_PORTD | GPIO_PF | GPIO_OUT | 22) +#define PD23_PF_CSPI2_MISO (GPIO_PORTD | GPIO_PF | GPIO_IN | 23) +#define PD24_PF_CSPI2_MOSI (GPIO_PORTD | GPIO_PF | GPIO_OUT | 24) #define PD25_PF_CSPI1_RDY (GPIO_PORTD | GPIO_PF | GPIO_OUT | 25) #define PD26_PF_CSPI1_SS2 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 26) #define PD27_PF_CSPI1_SS1 (GPIO_PORTD | GPIO_PF | GPIO_OUT | 27) diff --git a/arch/arm/mach-imx/include/mach/iomux-mx51.h b/arch/arm/mach-imx/include/mach/iomux-mx51.h index 0252d412c6..2623e7a2e1 100644 --- a/arch/arm/mach-imx/include/mach/iomux-mx51.h +++ b/arch/arm/mach-imx/include/mach/iomux-mx51.h @@ -107,11 +107,13 @@ #define MX51_PAD_EIM_D25__UART2_CTS IOMUX_PAD(0x414, 0x080, 4, __NA_, 0, MX51_UART_PAD_CTRL) #define MX51_PAD_EIM_D25__UART3_RXD IOMUX_PAD(0x414, 0x080, 3, 0x9f4, 0, MX51_UART_PAD_CTRL) #define MX51_PAD_EIM_D25__USBOTG_DATA1 IOMUX_PAD(0x414, 0x080, 2, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_EIM_D25__GPT_CMPOUT1 IOMUX_PAD(0x414, 0x080, 5, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_EIM_D26__EIM_D26 IOMUX_PAD(0x418, 0x084, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_EIM_D26__KEY_COL7 IOMUX_PAD(0x418, 0x084, 1, 0x9cc, 0, NO_PAD_CTRL) #define MX51_PAD_EIM_D26__UART2_RTS IOMUX_PAD(0x418, 0x084, 4, 0x9e8, 3, MX51_UART_PAD_CTRL) #define MX51_PAD_EIM_D26__UART3_TXD IOMUX_PAD(0x418, 0x084, 3, __NA_, 0, MX51_UART_PAD_CTRL) #define MX51_PAD_EIM_D26__USBOTG_DATA2 IOMUX_PAD(0x418, 0x084, 2, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_EIM_D26__GPT_CMPOUT2 IOMUX_PAD(0x418, 0x084, 5, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_EIM_D27__AUD6_RXC IOMUX_PAD(0x41c, 0x088, 5, 0x8f4, 0, NO_PAD_CTRL) #define MX51_PAD_EIM_D27__EIM_D27 IOMUX_PAD(0x41c, 0x088, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_EIM_D27__GPIO2_9 IOMUX_PAD(0x41c, 0x088, 1, __NA_, 0, MX51_GPIO_PAD_CTRL) @@ -228,6 +230,7 @@ #define MX51_PAD_EIM_CRE__EIM_CRE IOMUX_PAD(0x4a0, 0x100, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_EIM_CRE__GPIO3_2 IOMUX_PAD(0x4a0, 0x100, 1, 0x97c, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_DRAM_CS1__DRAM_CS1 IOMUX_PAD(0x4d0, 0x104, 0, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_DRAM_CS1__CCM_CLKO IOMUX_PAD(0x4d0, 0x104, 1, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_NANDF_WE_B__GPIO3_3 IOMUX_PAD(0x4e4, 0x108, 3, 0x980, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_NANDF_WE_B__NANDF_WE_B IOMUX_PAD(0x4e4, 0x108, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_NANDF_WE_B__PATA_DIOW IOMUX_PAD(0x4e4, 0x108, 1, __NA_, 0, NO_PAD_CTRL) @@ -256,12 +259,14 @@ #define MX51_PAD_NANDF_RB1__GPIO3_9 IOMUX_PAD(0x4fc, 0x120, 3, __NA_, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_NANDF_RB1__NANDF_RB1 IOMUX_PAD(0x4fc, 0x120, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_NANDF_RB1__PATA_IORDY IOMUX_PAD(0x4fc, 0x120, 1, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_NANDF_RB1__GPT_CMPOUT2 IOMUX_PAD(0x4fc, 0x120, 4, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_NANDF_RB1__SD4_CMD IOMUX_PAD(0x4fc, 0x120, 0x15, __NA_, 0, MX51_SDHCI_PAD_CTRL) #define MX51_PAD_NANDF_RB2__DISP2_WAIT IOMUX_PAD(0x500, 0x124, 5, 0x9a8, 0, NO_PAD_CTRL) #define MX51_PAD_NANDF_RB2__ECSPI2_SCLK IOMUX_PAD(0x500, 0x124, 2, __NA_, 0, MX51_ECSPI_PAD_CTRL) #define MX51_PAD_NANDF_RB2__FEC_COL IOMUX_PAD(0x500, 0x124, 1, 0x94c, 0, MX51_PAD_CTRL_2) #define MX51_PAD_NANDF_RB2__GPIO3_10 IOMUX_PAD(0x500, 0x124, 3, __NA_, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_NANDF_RB2__NANDF_RB2 IOMUX_PAD(0x500, 0x124, 0, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_NANDF_RB2__GPT_CMPOUT3 IOMUX_PAD(0x500, 0x124, 4, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_NANDF_RB2__USBH3_H3_DP IOMUX_PAD(0x500, 0x124, 0x17, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_NANDF_RB2__USBH3_NXT IOMUX_PAD(0x500, 0x124, 6, 0xa20, 0, NO_PAD_CTRL) #define MX51_PAD_NANDF_RB3__DISP1_WAIT IOMUX_PAD(0x504, 0x128, 5, __NA_, 0, NO_PAD_CTRL) @@ -637,7 +642,9 @@ #define MX51_PAD_DISP1_DAT23__DISP2_DAT17 IOMUX_PAD(0x728, 0x328, 5, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_DISP1_DAT23__DISP2_SER_CS IOMUX_PAD(0x728, 0x328, 4, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_DI1_PIN3__DI1_PIN3 IOMUX_PAD(0x72c, 0x32c, 0, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_DI1_DISP_CLK__DI1_DISP_CLK IOMUX_PAD(0x730, __NA_, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_DI1_PIN2__DI1_PIN2 IOMUX_PAD(0x734, 0x330, 0, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_DI1_PIN15__DI1_PIN15 IOMUX_PAD(0x738, __NA_, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_DI_GP2__DISP1_SER_CLK IOMUX_PAD(0x740, 0x338, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_DI_GP2__DISP2_WAIT IOMUX_PAD(0x740, 0x338, 2, 0x9a8, 1, NO_PAD_CTRL) #define MX51_PAD_DI_GP3__CSI1_DATA_EN IOMUX_PAD(0x744, 0x33c, 3, 0x9a0, 1, NO_PAD_CTRL) @@ -649,20 +656,20 @@ #define MX51_PAD_DI2_PIN2__DI2_PIN2 IOMUX_PAD(0x74c, 0x344, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_DI2_PIN2__FEC_MDC IOMUX_PAD(0x74c, 0x344, 2, __NA_, 0, MX51_PAD_CTRL_5) #define MX51_PAD_DI2_PIN3__DI2_PIN3 IOMUX_PAD(0x750, 0x348, 0, __NA_, 0, NO_PAD_CTRL) -#define MX51_PAD_DI2_PIN3__FEC_MDIO IOMUX_PAD(0x750, 0x348, 2, 0x954, 1, MX51_PAD_CTRL_5) +#define MX51_PAD_DI2_PIN3__FEC_MDIO IOMUX_PAD(0x750, 0x348, 2, 0x954, 1, NO_PAD_CTRL) #define MX51_PAD_DI2_DISP_CLK__DI2_DISP_CLK IOMUX_PAD(0x754, 0x34c, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_DI2_DISP_CLK__FEC_RDATA1 IOMUX_PAD(0x754, 0x34c, 2, 0x95c, 1, NO_PAD_CTRL) #define MX51_PAD_DI_GP4__DI2_PIN15 IOMUX_PAD(0x758, 0x350, 4, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_DI_GP4__DISP1_SER_DIN IOMUX_PAD(0x758, 0x350, 0, 0x9c0, 1, NO_PAD_CTRL) #define MX51_PAD_DI_GP4__DISP2_PIN1 IOMUX_PAD(0x758, 0x350, 3, __NA_, 0, NO_PAD_CTRL) -#define MX51_PAD_DI_GP4__FEC_RDATA2 IOMUX_PAD(0x758, 0x350, 2, 0x960, 1, MX51_PAD_CTRL_5) +#define MX51_PAD_DI_GP4__FEC_RDATA2 IOMUX_PAD(0x758, 0x350, 2, 0x960, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT0__DISP2_DAT0 IOMUX_PAD(0x75c, 0x354, 0, __NA_, 0, NO_PAD_CTRL) -#define MX51_PAD_DISP2_DAT0__FEC_RDATA3 IOMUX_PAD(0x75c, 0x354, 2, 0x964, 1, MX51_PAD_CTRL_5) +#define MX51_PAD_DISP2_DAT0__FEC_RDATA3 IOMUX_PAD(0x75c, 0x354, 2, 0x964, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT0__KEY_COL6 IOMUX_PAD(0x75c, 0x354, 4, 0x9c8, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT0__UART3_RXD IOMUX_PAD(0x75c, 0x354, 5, 0x9f4, 8, MX51_UART_PAD_CTRL) #define MX51_PAD_DISP2_DAT0__USBH3_CLK IOMUX_PAD(0x75c, 0x354, 3, 0x9f8, 1, MX51_UART_PAD_CTRL) #define MX51_PAD_DISP2_DAT1__DISP2_DAT1 IOMUX_PAD(0x760, 0x358, 0, __NA_, 0, NO_PAD_CTRL) -#define MX51_PAD_DISP2_DAT1__FEC_RX_ER IOMUX_PAD(0x760, 0x358, 2, 0x970, 1, MX51_PAD_CTRL_5) +#define MX51_PAD_DISP2_DAT1__FEC_RX_ER IOMUX_PAD(0x760, 0x358, 2, 0x970, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT1__KEY_COL7 IOMUX_PAD(0x760, 0x358, 4, 0x9cc, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT1__UART3_TXD IOMUX_PAD(0x760, 0x358, 5, __NA_, 0, MX51_UART_PAD_CTRL) #define MX51_PAD_DISP2_DAT1__USBH3_DIR IOMUX_PAD(0x760, 0x358, 3, 0xa1c, 1, NO_PAD_CTRL) @@ -692,17 +699,17 @@ #define MX51_PAD_DISP2_DAT9__USBH3_DATA1 IOMUX_PAD(0x780, 0x378, 3, 0xa00, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT10__DISP2_DAT10 IOMUX_PAD(0x784, 0x37c, 0, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT10__DISP2_SER_CS IOMUX_PAD(0x784, 0x37c, 5, __NA_, 0, NO_PAD_CTRL) -#define MX51_PAD_DISP2_DAT10__FEC_COL IOMUX_PAD(0x784, 0x37c, 2, 0x94c, 1, MX51_PAD_CTRL_5) +#define MX51_PAD_DISP2_DAT10__FEC_COL IOMUX_PAD(0x784, 0x37c, 2, 0x94c, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT10__KEY_ROW7 IOMUX_PAD(0x784, 0x37c, 4, 0x9dc, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT10__USBH3_DATA2 IOMUX_PAD(0x784, 0x37c, 3, 0xa04, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT11__AUD6_TXD IOMUX_PAD(0x788, 0x380, 4, 0x8f0, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT11__DISP2_DAT11 IOMUX_PAD(0x788, 0x380, 0, __NA_, 0, NO_PAD_CTRL) -#define MX51_PAD_DISP2_DAT11__FEC_RX_CLK IOMUX_PAD(0x788, 0x380, 2, 0x968, 1, MX51_PAD_CTRL_5) +#define MX51_PAD_DISP2_DAT11__FEC_RX_CLK IOMUX_PAD(0x788, 0x380, 2, 0x968, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT11__GPIO1_10 IOMUX_PAD(0x788, 0x380, 7, __NA_, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_DISP2_DAT11__USBH3_DATA3 IOMUX_PAD(0x788, 0x380, 3, 0xa08, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT12__AUD6_RXD IOMUX_PAD(0x78c, 0x384, 4, 0x8ec, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT12__DISP2_DAT12 IOMUX_PAD(0x78c, 0x384, 0, __NA_, 0, NO_PAD_CTRL) -#define MX51_PAD_DISP2_DAT12__FEC_RX_DV IOMUX_PAD(0x78c, 0x384, 2, 0x96c, 1, MX51_PAD_CTRL_5) +#define MX51_PAD_DISP2_DAT12__FEC_RX_DV IOMUX_PAD(0x78c, 0x384, 2, 0x96c, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT12__USBH3_DATA4 IOMUX_PAD(0x78c, 0x384, 3, 0xa0c, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT13__AUD6_TXC IOMUX_PAD(0x790, 0x388, 4, 0x8fc, 1, NO_PAD_CTRL) #define MX51_PAD_DISP2_DAT13__DISP2_DAT13 IOMUX_PAD(0x790, 0x388, 0, __NA_, 0, NO_PAD_CTRL) @@ -780,6 +787,8 @@ #define MX51_PAD_GPIO1_2__PWM1_PWMO IOMUX_PAD(0x7d4, 0x3cc, 1, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_3__GPIO1_3 IOMUX_PAD(0x7d8, 0x3d0, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_GPIO1_3__I2C2_SDA IOMUX_PAD(0x7d8, 0x3d0, 0x12, 0x9bc, 3, MX51_I2C_PAD_CTRL) +#define MX51_PAD_GPIO1_3__CCM_CLKO2 IOMUX_PAD(0x7d8, 0x3d0, 5, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_GPIO1_3__GPT_CLKIN IOMUX_PAD(0x7d8, 0x3d0, 6, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_3__PLL2_BYP IOMUX_PAD(0x7d8, 0x3d0, 7, 0x910, 1, NO_PAD_CTRL) #define MX51_PAD_GPIO1_3__PWM2_PWMO IOMUX_PAD(0x7d8, 0x3d0, 1, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_PMIC_INT_REQ__PMIC_INT_REQ IOMUX_PAD(0x7fc, 0x3d4, 0, __NA_, 0, NO_PAD_CTRL) @@ -788,13 +797,16 @@ #define MX51_PAD_GPIO1_4__EIM_RDY IOMUX_PAD(0x804, 0x3d8, 3, 0x938, 1, NO_PAD_CTRL) #define MX51_PAD_GPIO1_4__GPIO1_4 IOMUX_PAD(0x804, 0x3d8, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_GPIO1_4__WDOG1_WDOG_B IOMUX_PAD(0x804, 0x3d8, 2, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_GPIO1_4__GPT_CAPIN1 IOMUX_PAD(0x804, 0x3d8, 6, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_5__CSI2_MCLK IOMUX_PAD(0x808, 0x3dc, 6, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_5__DISP2_PIN16 IOMUX_PAD(0x808, 0x3dc, 3, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_5__GPIO1_5 IOMUX_PAD(0x808, 0x3dc, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_GPIO1_5__WDOG2_WDOG_B IOMUX_PAD(0x808, 0x3dc, 2, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_GPIO1_5__CCM_CLKO IOMUX_PAD(0x808, 0x3dc, 5, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_6__DISP2_PIN17 IOMUX_PAD(0x80c, 0x3e0, 4, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_6__GPIO1_6 IOMUX_PAD(0x80c, 0x3e0, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_GPIO1_6__REF_EN_B IOMUX_PAD(0x80c, 0x3e0, 3, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_GPIO1_6__GPT_CAPIN2 IOMUX_PAD(0x80c, 0x3e0, 6, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_7__CCM_OUT_0 IOMUX_PAD(0x810, 0x3e4, 3, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_7__GPIO1_7 IOMUX_PAD(0x810, 0x3e4, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_GPIO1_7__SD2_WP IOMUX_PAD(0x810, 0x3e4, 6, __NA_, 0, MX51_ESDHC_PAD_CTRL) @@ -803,11 +815,13 @@ #define MX51_PAD_GPIO1_8__GPIO1_8 IOMUX_PAD(0x814, 0x3e8, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_GPIO1_8__SD2_CD IOMUX_PAD(0x814, 0x3e8, 6, __NA_, 0, MX51_ESDHC_PAD_CTRL) #define MX51_PAD_GPIO1_8__USBH3_PWR IOMUX_PAD(0x814, 0x3e8, 1, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_GPIO1_8__CCM_CLKO2 IOMUX_PAD(0x814, 0x3e8, 4, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_9__CCM_OUT_1 IOMUX_PAD(0x818, 0x3ec, 3, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_9__DISP2_D1_CS IOMUX_PAD(0x818, 0x3ec, 2, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_9__DISP2_SER_CS IOMUX_PAD(0x818, 0x3ec, 7, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_9__GPIO1_9 IOMUX_PAD(0x818, 0x3ec, 0, __NA_, 0, MX51_GPIO_PAD_CTRL) #define MX51_PAD_GPIO1_9__SD2_LCTL IOMUX_PAD(0x818, 0x3ec, 6, __NA_, 0, NO_PAD_CTRL) #define MX51_PAD_GPIO1_9__USBH3_OC IOMUX_PAD(0x818, 0x3ec, 1, __NA_, 0, NO_PAD_CTRL) +#define MX51_PAD_GPIO1_9__CCM_CLKO IOMUX_PAD(0x818, 0x3ec, 4, __NA_, 0, NO_PAD_CTRL) #endif /* __MACH_IOMUX_MX51_H__ */ diff --git a/arch/arm/mach-imx/iomux-v3.c b/arch/arm/mach-imx/iomux-v3.c deleted file mode 100644 index 8a6064da6c..0000000000 --- a/arch/arm/mach-imx/iomux-v3.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2004-2006 Freescale Semiconductor, Inc. All Rights Reserved. - * Copyright (C) 2008 by Sascha Hauer <kernel@pengutronix.de> - * Copyright (C) 2009 by Jan Weitzel Phytec Messtechnik GmbH, - * <armlinux@phytec.de> - * - * 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 <common.h> -#include <init.h> -#include <io.h> -#include <mach/iomux-v3.h> - -static void __iomem *base; - -/* - * configures a single pad in the iomuxer - */ -int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t pad) -{ - u32 mux_ctrl_ofs = (pad & MUX_CTRL_OFS_MASK) >> MUX_CTRL_OFS_SHIFT; - u32 mux_mode = (pad & MUX_MODE_MASK) >> MUX_MODE_SHIFT; - u32 sel_input_ofs = (pad & MUX_SEL_INPUT_OFS_MASK) >> MUX_SEL_INPUT_OFS_SHIFT; - u32 sel_input = (pad & MUX_SEL_INPUT_MASK) >> MUX_SEL_INPUT_SHIFT; - u32 pad_ctrl_ofs = (pad & MUX_PAD_CTRL_OFS_MASK) >> MUX_PAD_CTRL_OFS_SHIFT; - u32 pad_ctrl = (pad & MUX_PAD_CTRL_MASK) >> MUX_PAD_CTRL_SHIFT; - - if (!base) - return -EINVAL; - - debug("%s: mux 0x%08x -> 0x%04x pad: 0x%08x -> 0x%04x sel_inp: 0x%08x -> 0x%04x\n", - __func__, mux_mode, mux_ctrl_ofs, pad_ctrl, pad_ctrl_ofs, sel_input, - sel_input_ofs); - - if (mux_ctrl_ofs) - __raw_writel(mux_mode, base + mux_ctrl_ofs); - - if (sel_input_ofs) - __raw_writel(sel_input, base + sel_input_ofs); - - if (!(pad_ctrl & NO_PAD_CTRL) && pad_ctrl_ofs) - __raw_writel(pad_ctrl, base + pad_ctrl_ofs); - - return 0; -} -EXPORT_SYMBOL(mxc_iomux_v3_setup_pad); - - -int mxc_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t *pad_list, unsigned count) -{ - iomux_v3_cfg_t *p = pad_list; - int i; - int ret; - - for (i = 0; i < count; i++) { - ret = mxc_iomux_v3_setup_pad(*p); - if (ret) - return ret; - p++; - } - return 0; -} -EXPORT_SYMBOL(mxc_iomux_v3_setup_multiple_pads); - -static int imx_iomux_probe(struct device_d *dev) -{ - base = dev_request_mem_region(dev, 0); - - return 0; -} - -static __maybe_unused struct of_device_id imx_iomux_dt_ids[] = { - { - .compatible = "fsl,imx35-iomux", - }, { - /* sentinel */ - } -}; - -static struct platform_device_id imx_iomux_ids[] = { - { - .name = "imx35-iomux", - }, { - /* sentinel */ - }, -}; - -static struct driver_d imx_iomux_driver = { - .name = "imx-iomuxv3", - .probe = imx_iomux_probe, - .of_compatible = DRV_OF_COMPAT(imx_iomux_dt_ids), - .id_table = imx_iomux_ids, -}; - -static int imx_iomux_init(void) -{ - return platform_driver_register(&imx_iomux_driver); -} -postcore_initcall(imx_iomux_init); diff --git a/arch/arm/mach-mxs/ocotp.c b/arch/arm/mach-mxs/ocotp.c index 84f38b580f..dd984467ef 100644 --- a/arch/arm/mach-mxs/ocotp.c +++ b/arch/arm/mach-mxs/ocotp.c @@ -44,6 +44,7 @@ struct ocotp_priv { struct cdev cdev; void __iomem *base; + unsigned int write_enable; }; static int mxs_ocotp_wait_busy(struct ocotp_priv *priv) @@ -103,18 +104,12 @@ static ssize_t mxs_ocotp_cdev_write(struct cdev *cdev, const void *buf, size_t c { struct ocotp_priv *priv = cdev->priv; void __iomem *base = priv->base; - const char *write_param; - unsigned int write_enabled = 0; unsigned long old_hclk, aligned_offset; int old_vddio, num_words, num_bytes, i, ret = 0; u8 *work_buf; u32 reg; - write_param = dev_get_param(cdev->dev, "permanent_write_enable"); - if (write_param) - write_enabled = simple_strtoul(write_param, NULL, 0); - - if (!write_param || !write_enabled) + if (!priv->write_enable) return -EPERM; /* we can only work on u32, so calc some helpers */ @@ -179,21 +174,6 @@ static struct file_operations mxs_ocotp_ops = { .lseek = dev_lseek_default, }; -static int mxs_ocotp_write_enable_set(struct device_d *dev, struct param_d *param, - const char *val) -{ - unsigned long write_enable; - - if (!val) - return -EINVAL; - - write_enable = simple_strtoul(val, NULL, 0); - if (write_enable > 1) - return -EINVAL; - - return dev_param_set_generic(dev, param, write_enable ? "1" : "0"); -} - static int mxs_ocotp_probe(struct device_d *dev) { int err; @@ -212,14 +192,8 @@ static int mxs_ocotp_probe(struct device_d *dev) if (IS_ENABLED(CONFIG_MXS_OCOTP_WRITABLE)) { mxs_ocotp_ops.write = mxs_ocotp_cdev_write; - - err = dev_add_param(dev, "permanent_write_enable", - mxs_ocotp_write_enable_set, NULL, 0); - if (err < 0) - return err; - err = dev_set_param(dev, "permanent_write_enable", "0"); - if (err < 0) - return err; + dev_add_param_bool(dev, "permanent_write_enable", + NULL, NULL, &priv->write_enable, NULL); } return 0; diff --git a/arch/arm/mach-mxs/soc-imx28.c b/arch/arm/mach-mxs/soc-imx28.c index 8972a3d909..ed931afc32 100644 --- a/arch/arm/mach-mxs/soc-imx28.c +++ b/arch/arm/mach-mxs/soc-imx28.c @@ -39,12 +39,16 @@ EXPORT_SYMBOL(reset_cpu); static int imx28_init(void) { + u32 reg; + /* * The default setting for the WDT is to do a POR. If the SoC is only * powered via battery, then a WDT reset powers the chip down instead * of resetting it. Use a software reset only. */ - writel(HW_CLKCTRL_WDOG_POR_DISABLE, IMX_CCM_BASE + HW_CLKCTRL_RESET); + reg = readl(IMX_CCM_BASE + HW_CLKCTRL_RESET) | + HW_CLKCTRL_WDOG_POR_DISABLE; + writel(reg, IMX_CCM_BASE + HW_CLKCTRL_RESET); return 0; } diff --git a/arch/arm/mach-netx/Kconfig b/arch/arm/mach-netx/Kconfig index 8d8f49b85d..3c62d605a9 100644 --- a/arch/arm/mach-netx/Kconfig +++ b/arch/arm/mach-netx/Kconfig @@ -9,35 +9,19 @@ config BOARDINFO config NETX_SDRAM_CTRL hex - default 0x010D0001 if MACH_NXDKN default 0x010D0121 if MACH_NXDB500 - default 0x030D0111 if MACH_NXHMIBB - default 0x010D0111 if MACH_NXEB500HMI - default 0x030D0001 if MACH_NXHX config NETX_SDRAM_TIMING_CTRL hex - default 0x03C12151 if MACH_NXDKN default 0x03C13261 if MACH_NXDB500 - default 0x03C13251 if MACH_NXHMIBB - default 0x03C13251 if MACH_NXEB500HMI - default 0x03C23251 if MACH_NXHX config NETX_MEM_CTRL hex - default 0x0103030F if MACH_NXDKN default 0x0203030F if MACH_NXDB500 - default 0x0103030F if MACH_NXHMIBB - default 0x0103030F if MACH_NXEB500HMI - default 0x0103030F if MACH_NXHX config NETX_COOKIE hex - default 16 if MACH_NXDKN default 32 if MACH_NXDB500 - default 16 if MACH_NXHMIBB - default 16 if MACH_NXEB500HMI - default 16 if MACH_NXHX choice prompt "Netx Board Type" diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig index 42e5f4af07..f7aa8c5a28 100644 --- a/arch/arm/mach-omap/Kconfig +++ b/arch/arm/mach-omap/Kconfig @@ -104,6 +104,13 @@ config OMAP4_USBBOOT You need the utility program omap4_usbboot to boot from USB. Please read omap4_usb_booting.txt for more information. +config CMD_BOOT_ORDER + tristate + depends on ARCH_OMAP4 + prompt "boot_order" + help + A command to choose the next boot device on a warm reset. + config BOARDINFO default "Archos G9" if MACH_ARCHOSG9 default "Texas Instrument's SDP343x" if MACH_OMAP343xSDP @@ -134,7 +141,6 @@ config MACH_BEAGLE config MACH_BEAGLEBONE bool "Texas Instrument's Beagle Bone" - select OMAP_CLOCK_ALL depends on ARCH_AM33XX help Say Y here if you are using Beagle Bone @@ -179,7 +185,6 @@ config MACH_PCAAXL2 config MACH_PCM051 bool "Phytec phyCORE pcm051" - select OMAP_CLOCK_ALL select HAVE_DEFAULT_ENVIRONMENT_NEW depends on ARCH_AM33XX help diff --git a/arch/arm/mach-omap/Makefile b/arch/arm/mach-omap/Makefile index d9e00f77ae..973068db58 100644 --- a/arch/arm/mach-omap/Makefile +++ b/arch/arm/mach-omap/Makefile @@ -30,4 +30,5 @@ obj-$(CONFIG_OMAP_GPMC) += gpmc.o devices-gpmc-nand.o obj-$(CONFIG_SHELL_NONE) += xload.o obj-$(CONFIG_MFD_TWL6030) += omap4_twl6030_mmc.o obj-$(CONFIG_OMAP4_USBBOOT) += omap4_rom_usb.o +obj-$(CONFIG_CMD_BOOT_ORDER) += boot_order.o obj-y += gpio.o diff --git a/arch/arm/mach-omap/am33xx_generic.c b/arch/arm/mach-omap/am33xx_generic.c index 059c55e3b0..96432c9ff2 100644 --- a/arch/arm/mach-omap/am33xx_generic.c +++ b/arch/arm/mach-omap/am33xx_generic.c @@ -19,12 +19,13 @@ */ #include <common.h> +#include <bootsource.h> +#include <init.h> #include <io.h> #include <net.h> #include <mach/am33xx-silicon.h> #include <mach/am33xx-clock.h> #include <mach/sys_info.h> -#include <mach/generic.h> #include <mach/am33xx-generic.h> void __noreturn reset_cpu(unsigned long addr) @@ -94,10 +95,13 @@ u32 running_in_sdram(void) return 0; /* running in SRAM or FLASH */ } -enum omap_boot_src am33xx_bootsrc(void) +static int am33xx_bootsource(void) { - return OMAP_BOOTSRC_MMC1; /* only MMC for now */ + bootsource_set(BOOTSOURCE_MMC); /* only MMC for now */ + bootsource_set_instance(0); + return 0; } +postcore_initcall(am33xx_bootsource); int am33xx_register_ethaddr(int eth_id, int mac_id) { diff --git a/arch/arm/mach-omap/boot_order.c b/arch/arm/mach-omap/boot_order.c new file mode 100644 index 0000000000..2f2846d119 --- /dev/null +++ b/arch/arm/mach-omap/boot_order.c @@ -0,0 +1,83 @@ +/* + * boot_order.c - configure omap warm boot + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * 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 <common.h> +#include <command.h> +#include <complete.h> +#include <mach/omap4-silicon.h> + +struct bootsrc { + const char *name; + uint32_t sar; +}; + +const struct bootsrc src_list[] = { + {"xip" , OMAP44XX_SAR_BOOT_XIP }, + {"xipwait" , OMAP44XX_SAR_BOOT_XIPWAIT }, + {"nand" , OMAP44XX_SAR_BOOT_NAND }, + {"onenand" , OMAP44XX_SAR_BOOT_ONENAND }, + {"mmc1" , OMAP44XX_SAR_BOOT_MMC1 }, + {"mmc2_1" , OMAP44XX_SAR_BOOT_MMC2_1 }, + {"mmc2_2" , OMAP44XX_SAR_BOOT_MMC2_2 }, + {"uart" , OMAP44XX_SAR_BOOT_UART }, + {"usb_1" , OMAP44XX_SAR_BOOT_USB_1 }, + {"usb_ulpi", OMAP44XX_SAR_BOOT_USB_ULPI}, + {"usb_2" , OMAP44XX_SAR_BOOT_USB_2 }, +}; + +static uint32_t parse_device(char *str) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(src_list); i++) { + if (strcmp(str, src_list[i].name) == 0) + return src_list[i].sar; + } + printf("Unknown device '%s'\n", str); + return OMAP44XX_SAR_BOOT_VOID; +} + +static int cmd_boot_order(int argc, char *argv[]) +{ + uint32_t device_list[] = { + OMAP44XX_SAR_BOOT_VOID, + OMAP44XX_SAR_BOOT_VOID, + OMAP44XX_SAR_BOOT_VOID, + OMAP44XX_SAR_BOOT_VOID, + }; + int i; + + if (argc < 2) + return COMMAND_ERROR_USAGE; + for (i = 0; i + 1 < argc && i < ARRAY_SIZE(device_list); i++) { + device_list[i] = parse_device(argv[i + 1]); + if (device_list[i] == OMAP44XX_SAR_BOOT_VOID) + return COMMAND_ERROR_USAGE; + } + omap4_set_warmboot_order(device_list); + return 0; +} + +static const __maybe_unused char cmd_boot_order_help[] = +"Usage: boot_order <device 1> [<device n>]\n" +"Set warm boot order of up to four devices.\n" +"Each device can be one of:\n" +"xip xipwait nand onenand mmc1 mmc2_1 mmc2_2 uart usb_1 usb_ulpi usb_2\n"; + +BAREBOX_CMD_START(boot_order) + .cmd = cmd_boot_order, + .usage = "boot_order <device 1> [<device n>]", + BAREBOX_CMD_HELP(cmd_boot_order_help) + BAREBOX_CMD_COMPLETE(empty_complete) +BAREBOX_CMD_END diff --git a/arch/arm/mach-omap/include/mach/am33xx-clock.h b/arch/arm/mach-omap/include/mach/am33xx-clock.h index 39c107f9c7..2ecfc5fc8d 100644 --- a/arch/arm/mach-omap/include/mach/am33xx-clock.h +++ b/arch/arm/mach-omap/include/mach/am33xx-clock.h @@ -31,12 +31,12 @@ #define MPUPLL_M_600 600 /* 125 * n */ #define MPUPLL_M_720 720 /* 125 * n */ -#define MPUPLL_N 23 /* (n -1 ) */ +#define MPUPLL_N (OSC - 1) #define MPUPLL_M2 1 /* Core PLL Fdll = 1 GHZ, */ #define COREPLL_M 1000 /* 125 * n */ -#define COREPLL_N 23 /* (n -1 ) */ +#define COREPLL_N (OSC - 1) #define COREPLL_M4 10 /* CORE_CLKOUTM4 = 200 MHZ */ #define COREPLL_M5 8 /* CORE_CLKOUTM5 = 250 MHZ */ @@ -48,19 +48,13 @@ * For clkout = 192 MHZ, Fdll = 960 MHZ, divider values are given below */ #define PERPLL_M 960 -#define PERPLL_N 23 +#define PERPLL_N (OSC - 1) #define PERPLL_M2 5 -/* DDR Freq is 166 MHZ for now*/ +/* DDR Freq is 266 MHZ for now*/ /* Set Fdll = 400 MHZ , Fdll = M * 2 * CLKINP/ N + 1; clkout = Fdll /(2 * M2) */ -//#if (CONFIG_AM335X_EVM_IS_13x13 == 1) -#if 0 -#define DDRPLL_M 166 /* M/N + 1 = 25/3 */ -#else #define DDRPLL_M 266 -#endif - -#define DDRPLL_N 23 +#define DDRPLL_N (OSC - 1) #define DDRPLL_M2 1 /* PRCM */ @@ -139,7 +133,9 @@ #define CM_PER_CPGMAC0_CLKCTRL (CM_PER + 0x14) /* Ethernet */ #define CM_PER_CPSW_CLKSTCTRL (CM_PER + 0x144)/* Ethernet */ #define CM_PER_OCMCRAM_CLKCTRL (CM_PER + 0x2C) /* OCMC RAM */ +#define CM_PER_GPIO1_CLKCTRL (CM_PER + 0xAC) /* GPIO1 */ #define CM_PER_GPIO2_CLKCTRL (CM_PER + 0xB0) /* GPIO2 */ +#define CM_PER_GPIO3_CLKCTRL (CM_PER + 0xB4) /* GPIO3 */ #define CM_PER_UART3_CLKCTRL (CM_PER + 0x74) /* UART3 */ #define CM_PER_I2C1_CLKCTRL (CM_PER + 0x48) /* I2C1 */ #define CM_PER_I2C2_CLKCTRL (CM_PER + 0x44) /* I2C2 */ diff --git a/arch/arm/mach-omap/include/mach/am33xx-silicon.h b/arch/arm/mach-omap/include/mach/am33xx-silicon.h index e69d345b07..9edf4ca977 100644 --- a/arch/arm/mach-omap/include/mach/am33xx-silicon.h +++ b/arch/arm/mach-omap/include/mach/am33xx-silicon.h @@ -29,6 +29,12 @@ #define AM33XX_UART1_BASE (AM33XX_L4_PER_BASE + 0x22000) #define AM33XX_UART2_BASE (AM33XX_L4_PER_BASE + 0x24000) +/* GPIO */ +#define AM33XX_GPIO0_BASE (AM33XX_L4_WKUP_BASE + 0x207000 + 0x100) +#define AM33XX_GPIO1_BASE (AM33XX_L4_PER_BASE + 0x4C000 + 0x100) +#define AM33XX_GPIO2_BASE (AM33XX_L4_PER_BASE + 0x1AC000 + 0x100) +#define AM33XX_GPIO3_BASE (AM33XX_L4_PER_BASE + 0x1AE000 + 0x100) + /* EMFI Registers */ #define AM33XX_EMFI0_BASE 0x4C000000 diff --git a/arch/arm/mach-omap/include/mach/generic.h b/arch/arm/mach-omap/include/mach/generic.h index 7455404ca5..5a10a548a9 100644 --- a/arch/arm/mach-omap/include/mach/generic.h +++ b/arch/arm/mach-omap/include/mach/generic.h @@ -27,17 +27,4 @@ #define cpu_is_omap4xxx() (0) #endif -enum omap_boot_src { - OMAP_BOOTSRC_UNKNOWN, - OMAP_BOOTSRC_MMC1, - OMAP_BOOTSRC_NAND, - OMAP_BOOTSRC_SPI1, - OMAP_BOOTSRC_USB1, -}; - -enum omap_boot_src omap_bootsrc(void); -enum omap_boot_src am33xx_bootsrc(void); -enum omap_boot_src omap3_bootsrc(void); -enum omap_boot_src omap4_bootsrc(void); - #endif diff --git a/arch/arm/mach-omap/include/mach/omap4-silicon.h b/arch/arm/mach-omap/include/mach/omap4-silicon.h index 9e82435e9c..666e721551 100644 --- a/arch/arm/mach-omap/include/mach/omap4-silicon.h +++ b/arch/arm/mach-omap/include/mach/omap4-silicon.h @@ -161,6 +161,25 @@ #define OMAP44XX_PRM_RSTCTRL_RESET 0x01 /* + * SAR (Save & Rescue) memory region + */ +#define OMAP44XX_SAR_RAM_BASE 0x4a326000 +#define OMAP44XX_SAR_CH_ADDRESS (OMAP44XX_SAR_RAM_BASE + 0xA00) +#define OMAP44XX_SAR_CH_START (OMAP44XX_SAR_RAM_BASE + 0xA0C) +#define OMAP44XX_SAR_BOOT_VOID 0x00 +#define OMAP44XX_SAR_BOOT_XIP 0x01 +#define OMAP44XX_SAR_BOOT_XIPWAIT 0x02 +#define OMAP44XX_SAR_BOOT_NAND 0x03 +#define OMAP44XX_SAR_BOOT_ONENAND 0x04 +#define OMAP44XX_SAR_BOOT_MMC1 0x05 +#define OMAP44XX_SAR_BOOT_MMC2_1 0x06 +#define OMAP44XX_SAR_BOOT_MMC2_2 0x07 +#define OMAP44XX_SAR_BOOT_UART 0x43 +#define OMAP44XX_SAR_BOOT_USB_1 0x45 +#define OMAP44XX_SAR_BOOT_USB_ULPI 0x46 +#define OMAP44XX_SAR_BOOT_USB_2 0x47 + +/* * Non-secure SRAM Addresses * Non-secure RAM starts at 0x40300000 for GP devices. But we keep SRAM_BASE * at 0x40304000(EMU base) so that our code works for both EMU and GP @@ -212,6 +231,7 @@ void omap4_ddr_init(const struct ddr_regs *, const struct dpll_param *); void omap4_power_i2c_send(u32); unsigned int omap4_revision(void); noinline int omap4_scale_vcores(unsigned vsel0_pin); +void omap4_set_warmboot_order(u32 *device_list); #endif diff --git a/arch/arm/mach-omap/omap3_clock.c b/arch/arm/mach-omap/omap3_clock.c index bcde48ff64..03aca492a1 100644 --- a/arch/arm/mach-omap/omap3_clock.c +++ b/arch/arm/mach-omap/omap3_clock.c @@ -652,12 +652,6 @@ void prcm_init(void) /** * @brief Enable the clks & power for perifs * - * GPT2 Sysclk, ICLK,FCLK, 32k Sync is enabled by default - * Uses CONFIG_OMAP_CLOCK_UART to enable UART clocks - * Uses CONFIG_OMAP_CLOCK_I2C to enable I2C clocks - * Uses CONFIG_OMAP_CLOCK_ALL to enable All Clocks! - * - Not a wise idea in most cases - * * @return void */ static void per_clocks_enable(void) diff --git a/arch/arm/mach-omap/omap3_generic.c b/arch/arm/mach-omap/omap3_generic.c index 10e03aec02..f144813cf9 100644 --- a/arch/arm/mach-omap/omap3_generic.c +++ b/arch/arm/mach-omap/omap3_generic.c @@ -28,6 +28,7 @@ */ #include <common.h> +#include <bootsource.h> #include <init.h> #include <io.h> #include <mach/omap3-silicon.h> @@ -40,7 +41,6 @@ #include <mach/wdt.h> #include <mach/sys_info.h> #include <mach/syslib.h> -#include <mach/generic.h> /** * @brief Reset the CPU @@ -461,21 +461,25 @@ void omap3_core_init(void) #ifdef CONFIG_OMAP3_CLOCK_CONFIG prcm_init(); #endif - } #define OMAP3_TRACING_VECTOR1 0x4020ffb4 -enum omap_boot_src omap3_bootsrc(void) +static int omap3_bootsource(void) { + enum bootsource src = BOOTSOURCE_UNKNOWN; u32 bootsrc = readl(OMAP3_TRACING_VECTOR1); if (bootsrc & (1 << 2)) - return OMAP_BOOTSRC_NAND; + src = BOOTSOURCE_NAND; if (bootsrc & (1 << 6)) - return OMAP_BOOTSRC_MMC1; - return OMAP_BOOTSRC_UNKNOWN; + src = BOOTSOURCE_MMC; + bootsource_set(src); + bootsource_set_instance(0); + + return 0; } +postcore_initcall(omap3_bootsource); /* GPMC timing for OMAP3 nand device */ const struct gpmc_config omap3_nand_cfg = { diff --git a/arch/arm/mach-omap/omap4_generic.c b/arch/arm/mach-omap/omap4_generic.c index e1edffa351..3d6ec25c93 100644 --- a/arch/arm/mach-omap/omap4_generic.c +++ b/arch/arm/mach-omap/omap4_generic.c @@ -1,11 +1,11 @@ #include <common.h> +#include <bootsource.h> #include <init.h> #include <io.h> #include <mach/omap4-clock.h> #include <mach/omap4-silicon.h> #include <mach/omap4-mux.h> #include <mach/syslib.h> -#include <mach/generic.h> #include <mach/gpmc.h> #include <mach/gpio.h> #include <mach/omap4_rom_usb.h> @@ -41,6 +41,26 @@ void __noreturn reset_cpu(unsigned long addr) while (1); } +void omap4_set_warmboot_order(u32 *device_list) +{ + const u32 CH[] = { + 0xCF00AA01, + 0x0000000C, + (device_list[0] << 16) | 0x0000, + (device_list[2] << 16) | device_list[1], + 0x0000 | device_list[3], + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000 + }; + int i; + + for (i = 0; i < ARRAY_SIZE(CH); i++) + writel(CH[i], OMAP44XX_SAR_CH_START + i*sizeof(CH[0])); + writel(OMAP44XX_SAR_CH_START, OMAP44XX_SAR_CH_ADDRESS); +} + #define WATCHDOG_WSPR 0x48 #define WATCHDOG_WWPS 0x34 @@ -339,7 +359,7 @@ void omap4_ddr_init(const struct ddr_regs *ddr_regs, /* PHY control values */ sr32(CM_MEMIF_EMIF_1_CLKCTRL, 0, 32, 0x1); - sr32(CM_MEMIF_EMIF_2_CLKCTRL, 0, 32, 0x1); + sr32(CM_MEMIF_EMIF_2_CLKCTRL, 0, 32, 0x1); /* Put the Core Subsystem PD to ON State */ @@ -466,7 +486,7 @@ static int omap_vector_init(void) * The ROM code uses interrupts for the transfers, so do not modify the * interrupt vectors in this case. */ - if (omap4_bootsrc() != OMAP_BOOTSRC_USB1) { + if (bootsource_get() != BOOTSOURCE_USB) { __asm__ __volatile__ ( "mov r0, #0;" "mcr p15, #0, r0, c12, c0, #0;" @@ -478,22 +498,28 @@ static int omap_vector_init(void) return 0; } -core_initcall(omap_vector_init); #define OMAP4_TRACING_VECTOR3 0x4030d048 -enum omap_boot_src omap4_bootsrc(void) +static int omap4_bootsource(void) { + enum bootsource src = BOOTSOURCE_UNKNOWN; u32 bootsrc = readl(OMAP4_TRACING_VECTOR3); if (bootsrc & (1 << 5)) - return OMAP_BOOTSRC_MMC1; + src = BOOTSOURCE_MMC; if (bootsrc & (1 << 3)) - return OMAP_BOOTSRC_NAND; + src = BOOTSOURCE_NAND; if (bootsrc & (1<<20)) - return OMAP_BOOTSRC_USB1; - return OMAP_BOOTSRC_UNKNOWN; + src = BOOTSOURCE_USB; + bootsource_set(src); + bootsource_set_instance(0); + + omap_vector_init(); + + return 0; } +core_initcall(omap4_bootsource); #define GPIO_MASK 0x1f diff --git a/arch/arm/mach-omap/omap_generic.c b/arch/arm/mach-omap/omap_generic.c index 580ed3e165..cfd3dec453 100644 --- a/arch/arm/mach-omap/omap_generic.c +++ b/arch/arm/mach-omap/omap_generic.c @@ -13,23 +13,12 @@ * */ #include <common.h> +#include <bootsource.h> #include <envfs.h> #include <init.h> #include <io.h> #include <fs.h> #include <linux/stat.h> -#include <mach/generic.h> - -enum omap_boot_src omap_bootsrc(void) -{ -#if defined(CONFIG_ARCH_OMAP3) - return omap3_bootsrc(); -#elif defined(CONFIG_ARCH_OMAP4) - return omap4_bootsrc(); -#elif defined(CONFIG_ARCH_AM33XX) - return am33xx_bootsrc(); -#endif -} #if defined(CONFIG_DEFAULT_ENVIRONMENT) && defined(CONFIG_MCI_STARTUP) static int omap_env_init(void) @@ -38,7 +27,7 @@ static int omap_env_init(void) char *diskdev = "/dev/disk0.0"; int ret; - if (omap_bootsrc() != OMAP_BOOTSRC_MMC1) + if (bootsource_get() != BOOTSOURCE_MMC) return 0; ret = stat(diskdev, &s); diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c index 72aa3791e4..3cce3f2be9 100644 --- a/arch/arm/mach-omap/xload.c +++ b/arch/arm/mach-omap/xload.c @@ -1,4 +1,5 @@ #include <common.h> +#include <bootsource.h> #include <partition.h> #include <nand.h> #include <init.h> @@ -6,7 +7,6 @@ #include <linux/mtd/mtd.h> #include <fs.h> #include <fcntl.h> -#include <mach/generic.h> #include <sizes.h> #include <filetype.h> @@ -165,30 +165,32 @@ static __noreturn int omap_xload(void) { int (*func)(void) = NULL; - switch (omap_bootsrc()) + switch (bootsource_get()) { - case OMAP_BOOTSRC_MMC1: - printf("booting from MMC1\n"); + case BOOTSOURCE_MMC: + printf("booting from MMC\n"); func = omap_xload_boot_mmc(); break; - case OMAP_BOOTSRC_USB1: + case BOOTSOURCE_USB: if (IS_ENABLED(CONFIG_FS_OMAP4_USBBOOT)) { - printf("booting from USB1\n"); + printf("booting from USB\n"); func = omap4_xload_boot_usb(); break; } else { - printf("booting from usb1 not enabled\n"); + printf("booting from USB not enabled\n"); } - case OMAP_BOOTSRC_UNKNOWN: - printf("unknown boot source. Fall back to nand\n"); - case OMAP_BOOTSRC_NAND: + case BOOTSOURCE_NAND: printf("booting from NAND\n"); func = omap_xload_boot_nand(SZ_128K); break; - case OMAP_BOOTSRC_SPI1: - printf("booting from SPI1\n"); + case BOOTSOURCE_SPI: + printf("booting from SPI\n"); func = omap_xload_boot_spi(SZ_128K); break; + default: + printf("unknown boot source. Fall back to nand\n"); + func = omap_xload_boot_nand(SZ_128K); + break; } if (!func) { diff --git a/arch/mips/boards/dlink-dir-320/config.h b/arch/mips/boards/dlink-dir-320/config.h deleted file mode 100644 index db5f0116fe..0000000000 --- a/arch/mips/boards/dlink-dir-320/config.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * 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. - * - * - */ - -/* nothing special yet */ diff --git a/arch/mips/boards/qemu-malta/config.h b/arch/mips/boards/qemu-malta/config.h deleted file mode 100644 index db5f0116fe..0000000000 --- a/arch/mips/boards/qemu-malta/config.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * 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. - * - * - */ - -/* nothing special yet */ diff --git a/arch/mips/boards/rzx50/config.h b/arch/mips/boards/rzx50/config.h deleted file mode 100644 index db5f0116fe..0000000000 --- a/arch/mips/boards/rzx50/config.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * 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. - * - * - */ - -/* nothing special yet */ diff --git a/arch/sandbox/board/config.h b/arch/sandbox/board/config.h deleted file mode 100644 index ca15136817..0000000000 --- a/arch/sandbox/board/config.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef __CONFIG_H -#define __CONFIG_H - -#endif /* __CONFIG_H */ diff --git a/arch/x86/boards/x86_generic/config.h b/arch/x86/boards/x86_generic/config.h deleted file mode 100644 index 473edb555c..0000000000 --- a/arch/x86/boards/x86_generic/config.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (C) 2009 Juergen Beisert, Pengutronix - * - * 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. - * - * - */ - -/* nothing special yet */ diff --git a/commands/Kconfig b/commands/Kconfig index 00627580ef..6a759ce204 100644 --- a/commands/Kconfig +++ b/commands/Kconfig @@ -303,17 +303,65 @@ config CMD_IOMEM config CMD_MEMORY bool default y - prompt "md and mw" + +config CMD_MD + tristate + default y + select CMD_MEMORY + prompt "md" + help + the md command allows to display (hexdump) memory locations and files. + +config CMD_MW + tristate + default y + select CMD_MEMORY + prompt "mw" + help + the mw command allows to write to memory locations and files. + +config CMD_MM + tristate + select CMD_MEMORY + prompt "memory modify (mm)" + help + the mm command allows to read-modify-write registers by doing: + reg = (reg & ~mask) | (val & mask) + +config CMD_MEMCMP + tristate + default y + select CMD_MEMORY + prompt "memcmp" + help + the memcmp command allows to compare memory and file regions. + +config CMD_MEMCPY + tristate + default y + select CMD_MEMORY + prompt "memcpy" + help + the memcpy command allows to copy memory and file regions. + +config CMD_MEMSET + tristate + default y + select CMD_MEMORY + prompt "memset" + help + the memset command allows to set regions of memory and files to + a specific value. config CMD_CRC tristate select CRC32 - prompt "crc" + prompt "crc32" config CMD_CRC_CMP tristate depends on CMD_CRC - prompt "compare 2 files crc" + prompt "compare 2 files using crc32" config CMD_DIGEST tristate diff --git a/commands/Makefile b/commands/Makefile index 0ae6b9546a..953ecc284b 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -7,6 +7,12 @@ obj-$(CONFIG_CMD_LOADY) += loadxy.o obj-$(CONFIG_CMD_LOADS) += loads.o obj-$(CONFIG_CMD_ECHO) += echo.o obj-$(CONFIG_CMD_MEMORY) += mem.o +obj-$(CONFIG_CMD_MD) += md.o +obj-$(CONFIG_CMD_MM) += mm.o +obj-$(CONFIG_CMD_MW) += mw.o +obj-$(CONFIG_CMD_MEMCMP) += memcmp.o +obj-$(CONFIG_CMD_MEMCPY) += memcpy.o +obj-$(CONFIG_CMD_MEMSET) += memset.o obj-$(CONFIG_CMD_MTEST) += memtest.o obj-$(CONFIG_CMD_EDIT) += edit.o obj-$(CONFIG_CMD_EXEC) += exec.o diff --git a/commands/bootm.c b/commands/bootm.c index e5dfc6ab3c..5dd1703538 100644 --- a/commands/bootm.c +++ b/commands/bootm.c @@ -127,9 +127,6 @@ static int bootm_open_initrd_uimage(struct image_data *data) data->initrd = data->os; } - if (data->initrd_address == UIMAGE_SOME_ADDRESS) - data->initrd_address = data->initrd->header.ih_load; - return 0; } @@ -256,7 +253,7 @@ static int do_bootm(int argc, char *argv[]) memset(&data, 0, sizeof(struct image_data)); - data.initrd_address = UIMAGE_SOME_ADDRESS; + data.initrd_address = UIMAGE_INVALID_ADDRESS; data.os_address = UIMAGE_SOME_ADDRESS; data.verify = 0; data.verbose = 0; @@ -408,8 +405,6 @@ static int do_bootm(int argc, char *argv[]) #endif if (data.os_address == UIMAGE_SOME_ADDRESS) data.os_address = UIMAGE_INVALID_ADDRESS; - if (data.initrd_address == UIMAGE_SOME_ADDRESS) - data.initrd_address = UIMAGE_INVALID_ADDRESS; handler = bootm_find_handler(os_type, &data); if (!handler) { diff --git a/commands/i2c.c b/commands/i2c.c index 8370b43dab..626255d612 100644 --- a/commands/i2c.c +++ b/commands/i2c.c @@ -45,7 +45,7 @@ static int do_i2c_probe(int argc, char *argv[]) if (stopaddr > 0x7F) stopaddr = 0x7F; - printf("probing i2c range 0X%02x - 0x%02x :\n", startaddr, stopaddr); + printf("probing i2c range 0x%02x - 0x%02x :\n", startaddr, stopaddr); for (addr = startaddr; addr <= stopaddr; addr++) { client.addr = addr; ret = i2c_write_reg(&client, 0x00, ®, 0); diff --git a/commands/md.c b/commands/md.c new file mode 100644 index 0000000000..03c5905bb6 --- /dev/null +++ b/commands/md.c @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2011 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * 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. + * + */ + +/* + * Memory Functions + * + * Copied from FADS ROM, Dan Malek (dmalek@jlc.net) + */ + +#include <common.h> +#include <command.h> +#include <init.h> +#include <driver.h> +#include <malloc.h> +#include <errno.h> +#include <fs.h> +#include <fcntl.h> +#include <getopt.h> +#include <linux/stat.h> +#include <xfuncs.h> + +extern char *mem_rw_buf; + +static int do_mem_md(int argc, char *argv[]) +{ + loff_t start = 0, size = 0x100; + int r, now; + int ret = 0; + int fd; + char *filename = "/dev/mem"; + int mode = O_RWSIZE_4; + int swab = 0; + + if (argc < 2) + return COMMAND_ERROR_USAGE; + + if (mem_parse_options(argc, argv, "bwls:x", &mode, &filename, NULL, + &swab) < 0) + return 1; + + if (optind < argc) { + if (parse_area_spec(argv[optind], &start, &size)) { + printf("could not parse: %s\n", argv[optind]); + return 1; + } + if (size == ~0) + size = 0x100; + } + + fd = open_and_lseek(filename, mode | O_RDONLY, start); + if (fd < 0) + return 1; + + do { + now = min(size, (loff_t)RW_BUF_SIZE); + r = read(fd, mem_rw_buf, now); + if (r < 0) { + perror("read"); + goto out; + } + if (!r) + goto out; + + if ((ret = memory_display(mem_rw_buf, start, r, + mode >> O_RWSIZE_SHIFT, swab))) + goto out; + + start += r; + size -= r; + } while (size); + +out: + close(fd); + + return ret ? 1 : 0; +} + +static const __maybe_unused char cmd_md_help[] = +"Usage md [OPTIONS] <region>\n" +"display (hexdump) a memory region.\n" +"options:\n" +" -s <file> display file (default /dev/mem)\n" +" -b output in bytes\n" +" -w output in halfwords (16bit)\n" +" -l output in words (32bit)\n" +" -x swap bytes at output\n" +"\n" +"Memory regions:\n" +"Memory regions can be specified in two different forms: start+size\n" +"or start-end, If <start> is omitted it defaults to 0. If end is omitted it\n" +"defaults to the end of the device, except for interactive commands like md\n" +"and mw for which it defaults to 0x100.\n" +"Sizes can be specified as decimal, or if prefixed with 0x as hexadecimal.\n" +"an optional suffix of k, M or G is for kibibytes, Megabytes or Gigabytes,\n" +"respectively\n"; + + +BAREBOX_CMD_START(md) + .cmd = do_mem_md, + .usage = "memory display", + BAREBOX_CMD_HELP(cmd_md_help) +BAREBOX_CMD_END diff --git a/commands/mem.c b/commands/mem.c index 51aa04daa2..7eb60afec3 100644 --- a/commands/mem.c +++ b/commands/mem.c @@ -39,80 +39,11 @@ #define PRINTF(fmt,args...) #endif -#define RW_BUF_SIZE 4096 -static char *rw_buf; +char *mem_rw_buf; static char *DEVMEM = "/dev/mem"; -/* Memory Display - * - * Syntax: - * md{.b, .w, .l} {addr} {len} - */ -#define DISP_LINE_LEN 16 - -int memory_display(char *addr, loff_t offs, ulong nbytes, int size, int swab) -{ - ulong linebytes, i; - u_char *cp; - - /* Print the lines. - * - * We buffer all read data, so we can make sure data is read only - * once, and all accesses are with the specified bus width. - */ - do { - char linebuf[DISP_LINE_LEN]; - uint *uip = (uint *)linebuf; - ushort *usp = (ushort *)linebuf; - u_char *ucp = (u_char *)linebuf; - uint count = 52; - - printf("%08llx:", offs); - linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes; - - for (i = 0; i < linebytes; i += size) { - if (size == 4) { - u32 res; - res = (*uip++ = *((uint *)addr)); - if (swab) - res = __swab32(res); - count -= printf(" %08x", res); - } else if (size == 2) { - u16 res; - res = (*usp++ = *((ushort *)addr)); - if (swab) - res = __swab16(res); - count -= printf(" %04x", res); - } else { - count -= printf(" %02x", (*ucp++ = *((u_char *)addr))); - } - addr += size; - offs += size; - } - - while(count--) - putchar(' '); - - cp = (u_char *)linebuf; - for (i=0; i<linebytes; i++) { - if ((*cp < 0x20) || (*cp > 0x7e)) - putchar('.'); - else - printf("%c", *cp); - cp++; - } - putchar('\n'); - nbytes -= linebytes; - if (ctrlc()) { - return -EINTR; - } - } while (nbytes > 0); - - return 0; -} - -static int open_and_lseek(const char *filename, int mode, loff_t pos) +int open_and_lseek(const char *filename, int mode, loff_t pos) { int fd, ret; @@ -135,7 +66,11 @@ static int open_and_lseek(const char *filename, int mode, loff_t pos) return fd; } -static int mem_parse_options(int argc, char *argv[], char *optstr, int *mode, +/* + * Common function for parsing options for the 'md', 'mw', 'memcpy', 'memcmp' + * commands. + */ +int mem_parse_options(int argc, char *argv[], char *optstr, int *mode, char **sourcefile, char **destfile, int *swab) { int opt; @@ -168,438 +103,6 @@ static int mem_parse_options(int argc, char *argv[], char *optstr, int *mode, return 0; } -static int do_mem_md(int argc, char *argv[]) -{ - loff_t start = 0, size = 0x100; - int r, now; - int ret = 0; - int fd; - char *filename = DEVMEM; - int mode = O_RWSIZE_4; - int swab = 0; - - if (argc < 2) - return COMMAND_ERROR_USAGE; - - if (mem_parse_options(argc, argv, "bwls:x", &mode, &filename, NULL, - &swab) < 0) - return 1; - - if (optind < argc) { - if (parse_area_spec(argv[optind], &start, &size)) { - printf("could not parse: %s\n", argv[optind]); - return 1; - } - if (size == ~0) - size = 0x100; - } - - fd = open_and_lseek(filename, mode | O_RDONLY, start); - if (fd < 0) - return 1; - - do { - now = min(size, (loff_t)RW_BUF_SIZE); - r = read(fd, rw_buf, now); - if (r < 0) { - perror("read"); - goto out; - } - if (!r) - goto out; - - if ((ret = memory_display(rw_buf, start, r, - mode >> O_RWSIZE_SHIFT, swab))) - goto out; - - start += r; - size -= r; - } while (size); - -out: - close(fd); - - return ret ? 1 : 0; -} - -static const __maybe_unused char cmd_md_help[] = -"Usage md [OPTIONS] <region>\n" -"display (hexdump) a memory region.\n" -"options:\n" -" -s <file> display file (default /dev/mem)\n" -" -b output in bytes\n" -" -w output in halfwords (16bit)\n" -" -l output in words (32bit)\n" -" -x swap bytes at output\n" -"\n" -"Memory regions:\n" -"Memory regions can be specified in two different forms: start+size\n" -"or start-end, If <start> is omitted it defaults to 0. If end is omitted it\n" -"defaults to the end of the device, except for interactive commands like md\n" -"and mw for which it defaults to 0x100.\n" -"Sizes can be specified as decimal, or if prefixed with 0x as hexadecimal.\n" -"an optional suffix of k, M or G is for kibibytes, Megabytes or Gigabytes,\n" -"respectively\n"; - - -BAREBOX_CMD_START(md) - .cmd = do_mem_md, - .usage = "memory display", - BAREBOX_CMD_HELP(cmd_md_help) -BAREBOX_CMD_END - -static int do_mem_mw(int argc, char *argv[]) -{ - int ret = 0; - int fd; - char *filename = DEVMEM; - int mode = O_RWSIZE_4; - loff_t adr; - int swab = 0; - - if (mem_parse_options(argc, argv, "bwld:x", &mode, NULL, &filename, - &swab) < 0) - return 1; - - if (optind + 1 >= argc) - return COMMAND_ERROR_USAGE; - - adr = strtoull_suffix(argv[optind++], NULL, 0); - - fd = open_and_lseek(filename, mode | O_WRONLY, adr); - if (fd < 0) - return 1; - - while (optind < argc) { - u8 val8; - u16 val16; - u32 val32; - switch (mode) { - case O_RWSIZE_1: - val8 = simple_strtoul(argv[optind], NULL, 0); - ret = write(fd, &val8, 1); - break; - case O_RWSIZE_2: - val16 = simple_strtoul(argv[optind], NULL, 0); - if (swab) - val16 = __swab16(val16); - ret = write(fd, &val16, 2); - break; - case O_RWSIZE_4: - val32 = simple_strtoul(argv[optind], NULL, 0); - if (swab) - val32 = __swab32(val32); - ret = write(fd, &val32, 4); - break; - } - if (ret < 0) { - perror("write"); - break; - } - ret = 0; - optind++; - } - - close(fd); - - return ret ? 1 : 0; -} - -static const __maybe_unused char cmd_mw_help[] = -"Usage: mw [OPTIONS] <region> <value(s)>\n" -"Write value(s) to the specifies region.\n" -"options:\n" -" -b, -w, -l use byte, halfword, or word accesses\n" -" -d <file> write file (default /dev/mem)\n"; - -BAREBOX_CMD_START(mw) - .cmd = do_mem_mw, - .usage = "memory write (fill)", - BAREBOX_CMD_HELP(cmd_mw_help) -BAREBOX_CMD_END - -static int do_mem_cmp(int argc, char *argv[]) -{ - loff_t addr1, addr2, count = ~0; - int mode = O_RWSIZE_1; - char *sourcefile = DEVMEM; - char *destfile = DEVMEM; - int sourcefd, destfd; - char *rw_buf1; - int ret = 1; - int offset = 0; - struct stat statbuf; - - if (mem_parse_options(argc, argv, "bwls:d:", &mode, &sourcefile, - &destfile, NULL) < 0) - return 1; - - if (optind + 2 > argc) - return COMMAND_ERROR_USAGE; - - addr1 = strtoull_suffix(argv[optind], NULL, 0); - addr2 = strtoull_suffix(argv[optind + 1], NULL, 0); - - if (optind + 2 == argc) { - if (sourcefile == DEVMEM) { - printf("source and count not given\n"); - return 1; - } - if (stat(sourcefile, &statbuf)) { - perror("stat"); - return 1; - } - count = statbuf.st_size - addr1; - } else { - count = strtoull_suffix(argv[optind + 2], NULL, 0); - } - - sourcefd = open_and_lseek(sourcefile, mode | O_RDONLY, addr1); - if (sourcefd < 0) - return 1; - - destfd = open_and_lseek(destfile, mode | O_RDONLY, addr2); - if (destfd < 0) { - close(sourcefd); - return 1; - } - - rw_buf1 = xmalloc(RW_BUF_SIZE); - - while (count > 0) { - int now, r1, r2, i; - - now = min((loff_t)RW_BUF_SIZE, count); - - r1 = read(sourcefd, rw_buf, now); - if (r1 < 0) { - perror("read"); - goto out; - } - - r2 = read(destfd, rw_buf1, now); - if (r2 < 0) { - perror("read"); - goto out; - } - - if (r1 != now || r2 != now) { - printf("regions differ in size\n"); - goto out; - } - - for (i = 0; i < now; i++) { - if (rw_buf[i] != rw_buf1[i]) { - printf("files differ at offset %d\n", offset); - goto out; - } - offset++; - } - - count -= now; - } - - printf("OK\n"); - ret = 0; -out: - close(sourcefd); - close(destfd); - free(rw_buf1); - - return ret; -} - -static const __maybe_unused char cmd_memcmp_help[] = -"Usage: memcmp [OPTIONS] <addr1> <addr2> <count>\n" -"\n" -"options:\n" -" -b, -w, -l use byte, halfword, or word accesses\n" -" -s <file> source file (default /dev/mem)\n" -" -d <file> destination file (default /dev/mem)\n" -"\n" -"Compare memory regions specified with addr1 and addr2\n" -"of size <count> bytes. If source is a file count can\n" -"be left unspecified in which case the whole file is\n" -"compared\n"; - -BAREBOX_CMD_START(memcmp) - .cmd = do_mem_cmp, - .usage = "memory compare", - BAREBOX_CMD_HELP(cmd_memcmp_help) -BAREBOX_CMD_END - -static int do_mem_cp(int argc, char *argv[]) -{ - loff_t count, dest, src; - char *sourcefile = DEVMEM; - char *destfile = DEVMEM; - int sourcefd, destfd; - int mode = 0; - struct stat statbuf; - int ret = 0; - - if (mem_parse_options(argc, argv, "bwls:d:", &mode, &sourcefile, - &destfile, NULL) < 0) - return 1; - - if (optind + 2 > argc) - return COMMAND_ERROR_USAGE; - - src = strtoull_suffix(argv[optind], NULL, 0); - dest = strtoull_suffix(argv[optind + 1], NULL, 0); - - if (optind + 2 == argc) { - if (sourcefile == DEVMEM) { - printf("source and count not given\n"); - return 1; - } - if (stat(sourcefile, &statbuf)) { - perror("stat"); - return 1; - } - count = statbuf.st_size - src; - } else { - count = strtoull_suffix(argv[optind + 2], NULL, 0); - } - - sourcefd = open_and_lseek(sourcefile, mode | O_RDONLY, src); - if (sourcefd < 0) - return 1; - - destfd = open_and_lseek(destfile, O_WRONLY | O_CREAT | mode, dest); - if (destfd < 0) { - close(sourcefd); - return 1; - } - - while (count > 0) { - int now, r, w, tmp; - - now = min((loff_t)RW_BUF_SIZE, count); - - r = read(sourcefd, rw_buf, now); - if (r < 0) { - perror("read"); - goto out; - } - - if (!r) - break; - - tmp = 0; - now = r; - while (now) { - w = write(destfd, rw_buf + tmp, now); - if (w < 0) { - perror("write"); - goto out; - } - if (!w) - break; - - now -= w; - tmp += w; - } - - count -= r; - - if (ctrlc()) - goto out; - } - - if (count) { - printf("ran out of data\n"); - ret = 1; - } - -out: - close(sourcefd); - close(destfd); - - return ret; -} - -static const __maybe_unused char cmd_memcpy_help[] = -"Usage: memcpy [OPTIONS] <src> <dst> <count>\n" -"\n" -"options:\n" -" -b, -w, -l use byte, halfword, or word accesses\n" -" -s <file> source file (default /dev/mem)\n" -" -d <file> destination file (default /dev/mem)\n" -"\n" -"Copy memory at <src> of <count> bytes to <dst>\n"; - -BAREBOX_CMD_START(memcpy) - .cmd = do_mem_cp, - .usage = "memory copy", - BAREBOX_CMD_HELP(cmd_memcpy_help) -BAREBOX_CMD_END - -static int do_memset(int argc, char *argv[]) -{ - loff_t s, c, n; - int fd; - char *buf; - int mode = O_RWSIZE_1; - int ret = 1; - char *file = DEVMEM; - - if (mem_parse_options(argc, argv, "bwld:", &mode, NULL, &file, - NULL) < 0) - return 1; - - if (optind + 3 > argc) - return COMMAND_ERROR_USAGE; - - s = strtoull_suffix(argv[optind], NULL, 0); - c = strtoull_suffix(argv[optind + 1], NULL, 0); - n = strtoull_suffix(argv[optind + 2], NULL, 0); - - fd = open_and_lseek(file, mode | O_WRONLY, s); - if (fd < 0) - return 1; - - buf = xmalloc(RW_BUF_SIZE); - memset(buf, c, RW_BUF_SIZE); - - while (n > 0) { - int now; - - now = min((loff_t)RW_BUF_SIZE, n); - - ret = write(fd, buf, now); - if (ret < 0) { - perror("write"); - ret = 1; - goto out; - } - - n -= now; - } - - ret = 0; -out: - close(fd); - free(buf); - - return ret; -} - -static const __maybe_unused char cmd_memset_help[] = -"Usage: memset [OPTIONS] <addr> <c> <n>\n" -"\n" -"options:\n" -" -b, -w, -l use byte, halfword, or word accesses\n" -" -d <file> destination file (default /dev/mem)\n" -"\n" -"Fill the first <n> bytes at offset <addr> with byte <c>\n"; - -BAREBOX_CMD_START(memset) - .cmd = do_memset, - .usage = "memory fill", - BAREBOX_CMD_HELP(cmd_memset_help) -BAREBOX_CMD_END - static struct file_operations memops = { .read = mem_read, .write = mem_write, @@ -631,16 +134,11 @@ static struct driver_d mem_drv = { static int mem_init(void) { - rw_buf = malloc(RW_BUF_SIZE); - if(!rw_buf) { - printf("%s: Out of memory\n", __FUNCTION__); - return -1; - } + mem_rw_buf = malloc(RW_BUF_SIZE); + if(!mem_rw_buf) + return -ENOMEM; add_mem_device("mem", 0, ~0, IORESOURCE_MEM_WRITEABLE); - platform_driver_register(&mem_drv); - - return 0; + return platform_driver_register(&mem_drv); } - device_initcall(mem_init); diff --git a/commands/memcmp.c b/commands/memcmp.c new file mode 100644 index 0000000000..4a03862541 --- /dev/null +++ b/commands/memcmp.c @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2011 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * 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. + * + */ + +/* + * Memory Functions + * + * Copied from FADS ROM, Dan Malek (dmalek@jlc.net) + */ + +#include <common.h> +#include <command.h> +#include <init.h> +#include <driver.h> +#include <malloc.h> +#include <errno.h> +#include <fs.h> +#include <fcntl.h> +#include <getopt.h> +#include <linux/stat.h> +#include <xfuncs.h> + +extern char *mem_rw_buf; + +static char *devmem = "/dev/mem"; + +static int do_memcmp(int argc, char *argv[]) +{ + loff_t addr1, addr2, count = ~0; + int mode = O_RWSIZE_1; + char *sourcefile = devmem; + char *destfile = devmem; + int sourcefd, destfd; + char *rw_buf1; + int ret = 1; + int offset = 0; + struct stat statbuf; + + if (mem_parse_options(argc, argv, "bwls:d:", &mode, &sourcefile, + &destfile, NULL) < 0) + return 1; + + if (optind + 2 > argc) + return COMMAND_ERROR_USAGE; + + addr1 = strtoull_suffix(argv[optind], NULL, 0); + addr2 = strtoull_suffix(argv[optind + 1], NULL, 0); + + if (optind + 2 == argc) { + if (sourcefile == devmem) { + printf("source and count not given\n"); + return 1; + } + if (stat(sourcefile, &statbuf)) { + perror("stat"); + return 1; + } + count = statbuf.st_size - addr1; + } else { + count = strtoull_suffix(argv[optind + 2], NULL, 0); + } + + sourcefd = open_and_lseek(sourcefile, mode | O_RDONLY, addr1); + if (sourcefd < 0) + return 1; + + destfd = open_and_lseek(destfile, mode | O_RDONLY, addr2); + if (destfd < 0) { + close(sourcefd); + return 1; + } + + rw_buf1 = xmalloc(RW_BUF_SIZE); + + while (count > 0) { + int now, r1, r2, i; + + now = min((loff_t)RW_BUF_SIZE, count); + + r1 = read(sourcefd, mem_rw_buf, now); + if (r1 < 0) { + perror("read"); + goto out; + } + + r2 = read(destfd, rw_buf1, now); + if (r2 < 0) { + perror("read"); + goto out; + } + + if (r1 != now || r2 != now) { + printf("regions differ in size\n"); + goto out; + } + + for (i = 0; i < now; i++) { + if (mem_rw_buf[i] != rw_buf1[i]) { + printf("files differ at offset %d\n", offset); + goto out; + } + offset++; + } + + count -= now; + } + + printf("OK\n"); + ret = 0; +out: + close(sourcefd); + close(destfd); + free(rw_buf1); + + return ret; +} + +static const __maybe_unused char cmd_memcmp_help[] = +"Usage: memcmp [OPTIONS] <addr1> <addr2> <count>\n" +"\n" +"options:\n" +" -b, -w, -l use byte, halfword, or word accesses\n" +" -s <file> source file (default /dev/mem)\n" +" -d <file> destination file (default /dev/mem)\n" +"\n" +"Compare memory regions specified with addr1 and addr2\n" +"of size <count> bytes. If source is a file count can\n" +"be left unspecified in which case the whole file is\n" +"compared\n"; + +BAREBOX_CMD_START(memcmp) + .cmd = do_memcmp, + .usage = "memory compare", + BAREBOX_CMD_HELP(cmd_memcmp_help) +BAREBOX_CMD_END diff --git a/commands/memcpy.c b/commands/memcpy.c new file mode 100644 index 0000000000..98f099f18d --- /dev/null +++ b/commands/memcpy.c @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2011 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * 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. + * + */ + +/* + * Memory Functions + * + * Copied from FADS ROM, Dan Malek (dmalek@jlc.net) + */ + +#include <common.h> +#include <command.h> +#include <init.h> +#include <driver.h> +#include <malloc.h> +#include <errno.h> +#include <fs.h> +#include <fcntl.h> +#include <getopt.h> +#include <linux/stat.h> +#include <xfuncs.h> + +extern char *mem_rw_buf; + +static char *devmem = "/dev/mem"; + +static int do_memcpy(int argc, char *argv[]) +{ + loff_t count, dest, src; + char *sourcefile = devmem; + char *destfile = devmem; + int sourcefd, destfd; + int mode = 0; + struct stat statbuf; + int ret = 0; + + if (mem_parse_options(argc, argv, "bwls:d:", &mode, &sourcefile, + &destfile, NULL) < 0) + return 1; + + if (optind + 2 > argc) + return COMMAND_ERROR_USAGE; + + src = strtoull_suffix(argv[optind], NULL, 0); + dest = strtoull_suffix(argv[optind + 1], NULL, 0); + + if (optind + 2 == argc) { + if (sourcefile == devmem) { + printf("source and count not given\n"); + return 1; + } + if (stat(sourcefile, &statbuf)) { + perror("stat"); + return 1; + } + count = statbuf.st_size - src; + } else { + count = strtoull_suffix(argv[optind + 2], NULL, 0); + } + + sourcefd = open_and_lseek(sourcefile, mode | O_RDONLY, src); + if (sourcefd < 0) + return 1; + + destfd = open_and_lseek(destfile, O_WRONLY | O_CREAT | mode, dest); + if (destfd < 0) { + close(sourcefd); + return 1; + } + + while (count > 0) { + int now, r, w, tmp; + + now = min((loff_t)RW_BUF_SIZE, count); + + r = read(sourcefd, mem_rw_buf, now); + if (r < 0) { + perror("read"); + goto out; + } + + if (!r) + break; + + tmp = 0; + now = r; + while (now) { + w = write(destfd, mem_rw_buf + tmp, now); + if (w < 0) { + perror("write"); + goto out; + } + if (!w) + break; + + now -= w; + tmp += w; + } + + count -= r; + + if (ctrlc()) + goto out; + } + + if (count) { + printf("ran out of data\n"); + ret = 1; + } + +out: + close(sourcefd); + close(destfd); + + return ret; +} + +static const __maybe_unused char cmd_memcpy_help[] = +"Usage: memcpy [OPTIONS] <src> <dst> <count>\n" +"\n" +"options:\n" +" -b, -w, -l use byte, halfword, or word accesses\n" +" -s <file> source file (default /dev/mem)\n" +" -d <file> destination file (default /dev/mem)\n" +"\n" +"Copy memory at <src> of <count> bytes to <dst>\n"; + +BAREBOX_CMD_START(memcpy) + .cmd = do_memcpy, + .usage = "memory copy", + BAREBOX_CMD_HELP(cmd_memcpy_help) +BAREBOX_CMD_END diff --git a/commands/memset.c b/commands/memset.c new file mode 100644 index 0000000000..48e55bc68e --- /dev/null +++ b/commands/memset.c @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2011 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * 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. + * + */ + +/* + * Memory Functions + * + * Copied from FADS ROM, Dan Malek (dmalek@jlc.net) + */ + +#include <common.h> +#include <command.h> +#include <init.h> +#include <driver.h> +#include <malloc.h> +#include <errno.h> +#include <fs.h> +#include <fcntl.h> +#include <getopt.h> +#include <linux/stat.h> +#include <xfuncs.h> + +extern char *mem_rw_buf; + +static int do_memset(int argc, char *argv[]) +{ + loff_t s, c, n; + int fd; + char *buf; + int mode = O_RWSIZE_1; + int ret = 1; + char *file = "/dev/mem"; + + if (mem_parse_options(argc, argv, "bwld:", &mode, NULL, &file, + NULL) < 0) + return 1; + + if (optind + 3 > argc) + return COMMAND_ERROR_USAGE; + + s = strtoull_suffix(argv[optind], NULL, 0); + c = strtoull_suffix(argv[optind + 1], NULL, 0); + n = strtoull_suffix(argv[optind + 2], NULL, 0); + + fd = open_and_lseek(file, mode | O_WRONLY, s); + if (fd < 0) + return 1; + + buf = xmalloc(RW_BUF_SIZE); + memset(buf, c, RW_BUF_SIZE); + + while (n > 0) { + int now; + + now = min((loff_t)RW_BUF_SIZE, n); + + ret = write(fd, buf, now); + if (ret < 0) { + perror("write"); + ret = 1; + goto out; + } + + n -= now; + } + + ret = 0; +out: + close(fd); + free(buf); + + return ret; +} + +static const __maybe_unused char cmd_memset_help[] = +"Usage: memset [OPTIONS] <addr> <c> <n>\n" +"\n" +"options:\n" +" -b, -w, -l use byte, halfword, or word accesses\n" +" -d <file> destination file (default /dev/mem)\n" +"\n" +"Fill the first <n> bytes at offset <addr> with byte <c>\n"; + +BAREBOX_CMD_START(memset) + .cmd = do_memset, + .usage = "memory fill", + BAREBOX_CMD_HELP(cmd_memset_help) +BAREBOX_CMD_END diff --git a/commands/mm.c b/commands/mm.c new file mode 100644 index 0000000000..f51fd27cb0 --- /dev/null +++ b/commands/mm.c @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2013 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * 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 <common.h> +#include <command.h> +#include <init.h> +#include <driver.h> +#include <malloc.h> +#include <errno.h> +#include <fs.h> +#include <fcntl.h> +#include <getopt.h> +#include <linux/stat.h> +#include <xfuncs.h> + +static int do_mem_mm(int argc, char *argv[]) +{ + int ret = 0; + int fd; + char *filename = "/dev/mem"; + int mode = O_RWSIZE_4; + loff_t adr; + int swab = 0; + u8 val8; + u16 val16; + u32 val32; + u32 value, mask; + + if (mem_parse_options(argc, argv, "bwld:", &mode, NULL, &filename, + &swab) < 0) + return 1; + + if (optind + 2 >= argc) + return COMMAND_ERROR_USAGE; + + adr = strtoull_suffix(argv[optind++], NULL, 0); + value = simple_strtoul(argv[optind++], NULL, 0); + mask = simple_strtoul(argv[optind++], NULL, 0); + + fd = open_and_lseek(filename, mode | O_RDWR, adr); + if (fd < 0) + return 1; + + switch (mode) { + case O_RWSIZE_1: + ret = pread(fd, &val8, 1, adr); + if (ret < 0) + goto out_read; + val8 &= ~mask; + val8 |= (value & mask); + ret = pwrite(fd, &val8, 1, adr); + if (ret < 0) + goto out_write; + break; + case O_RWSIZE_2: + ret = pread(fd, &val16, 2, adr); + if (ret < 0) + goto out_read; + val16 &= ~mask; + val16 |= (value & mask); + ret = pwrite(fd, &val16, 2, adr); + if (ret < 0) + goto out_write; + break; + case O_RWSIZE_4: + if (ret < 0) + goto out_read; + ret = pread(fd, &val32, 4, adr); + val32 &= ~mask; + val32 |= (value & mask); + ret = pwrite(fd, &val32, 4, adr); + if (ret < 0) + goto out_write; + break; + } + + close(fd); + + return 0; + +out_read: + perror("read"); + close(fd); + return 1; + +out_write: + perror("write"); + close(fd); + return 1; +} + +static const __maybe_unused char cmd_mm_help[] = +"Usage: mm [OPTIONS] <adr> <val> <mask>\n" +"set/clear bits specified with <mask> in <adr> to <value>\n" +"options:\n" +" -b, -w, -l use byte, halfword, or word accesses\n" +" -d <file> write file (default /dev/mem)\n"; + +BAREBOX_CMD_START(mm) + .cmd = do_mem_mm, + .usage = "memory modify write with mask", + BAREBOX_CMD_HELP(cmd_mm_help) +BAREBOX_CMD_END diff --git a/commands/mw.c b/commands/mw.c new file mode 100644 index 0000000000..d7d73a8f43 --- /dev/null +++ b/commands/mw.c @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2011 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * 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. + * + */ + +/* + * Memory Functions + * + * Copied from FADS ROM, Dan Malek (dmalek@jlc.net) + */ + +#include <common.h> +#include <command.h> +#include <init.h> +#include <driver.h> +#include <malloc.h> +#include <errno.h> +#include <fs.h> +#include <fcntl.h> +#include <getopt.h> +#include <linux/stat.h> +#include <xfuncs.h> + +static int do_mem_mw(int argc, char *argv[]) +{ + int ret = 0; + int fd; + char *filename = "/dev/mem"; + int mode = O_RWSIZE_4; + loff_t adr; + int swab = 0; + + if (mem_parse_options(argc, argv, "bwld:x", &mode, NULL, &filename, + &swab) < 0) + return 1; + + if (optind + 1 >= argc) + return COMMAND_ERROR_USAGE; + + adr = strtoull_suffix(argv[optind++], NULL, 0); + + fd = open_and_lseek(filename, mode | O_WRONLY, adr); + if (fd < 0) + return 1; + + while (optind < argc) { + u8 val8; + u16 val16; + u32 val32; + switch (mode) { + case O_RWSIZE_1: + val8 = simple_strtoul(argv[optind], NULL, 0); + ret = write(fd, &val8, 1); + break; + case O_RWSIZE_2: + val16 = simple_strtoul(argv[optind], NULL, 0); + if (swab) + val16 = __swab16(val16); + ret = write(fd, &val16, 2); + break; + case O_RWSIZE_4: + val32 = simple_strtoul(argv[optind], NULL, 0); + if (swab) + val32 = __swab32(val32); + ret = write(fd, &val32, 4); + break; + } + if (ret < 0) { + perror("write"); + break; + } + ret = 0; + optind++; + } + + close(fd); + + return ret ? 1 : 0; +} + +static const __maybe_unused char cmd_mw_help[] = +"Usage: mw [OPTIONS] <region> <value(s)>\n" +"Write value(s) to the specifies region.\n" +"options:\n" +" -b, -w, -l use byte, halfword, or word accesses\n" +" -d <file> write file (default /dev/mem)\n"; + +BAREBOX_CMD_START(mw) + .cmd = do_mem_mw, + .usage = "memory write (fill)", + BAREBOX_CMD_HELP(cmd_mw_help) +BAREBOX_CMD_END diff --git a/commands/of_property.c b/commands/of_property.c index 6311b7022a..44bb38801e 100644 --- a/commands/of_property.c +++ b/commands/of_property.c @@ -62,7 +62,7 @@ static int of_parse_prop_cells(char * const *newval, int count, char *data, int /* If the ptr didn't advance, something went wrong */ if ((newp - cp) <= 0) { - printf("cannot not convert \"%s\"\n", cp); + printf("cannot convert \"%s\"\n", cp); return -EINVAL; } @@ -105,7 +105,7 @@ static int of_parse_prop_stream(char * const *newval, int count, char *data, int /* If the ptr didn't advance, something went wrong */ if ((newp - cp) <= 0) { - printf("cannot not convert \"%s\"\n", cp); + printf("cannot convert \"%s\"\n", cp); return -EINVAL; } } diff --git a/commands/ubi.c b/commands/ubi.c index 1653eaa486..73483948b7 100644 --- a/commands/ubi.c +++ b/commands/ubi.c @@ -47,7 +47,7 @@ static int do_ubimkvol(int argc, char *argv[]) static const __maybe_unused char cmd_ubimkvol_help[] = "Usage: ubimkvol <ubidev> <name> <size>\n" "Create an ubi volume on <ubidev> with name <name> and size <size>\n" -"If size os zero all available space is used for the volume\n"; +"If size is zero all available space is used for the volume\n"; BAREBOX_CMD_START(ubimkvol) .cmd = do_ubimkvol, diff --git a/common/Makefile b/common/Makefile index dcb07c271c..94601728d3 100644 --- a/common/Makefile +++ b/common/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_CMD_LOADS) += s_record.o obj-$(CONFIG_OFTREE) += oftree.o obj-y += memory.o +obj-y += memory_display.o obj-$(CONFIG_MALLOC_DLMALLOC) += dlmalloc.o obj-$(CONFIG_MALLOC_TLSF) += tlsf_malloc.o obj-$(CONFIG_MALLOC_TLSF) += tlsf.o diff --git a/common/console.c b/common/console.c index beb37bddc1..a0a06f6300 100644 --- a/common/console.c +++ b/common/console.c @@ -99,33 +99,22 @@ static int console_std_set(struct device_d *dev, struct param_d *param, return 0; } -static int console_baudrate_set(struct device_d *dev, struct param_d *param, - const char *val) +static int console_baudrate_set(struct param_d *param, void *priv) { - struct console_device *cdev = to_console_dev(dev); - int baudrate; - char baudstr[16]; + struct console_device *cdev = priv; unsigned char c; - if (!val) - dev_param_set_generic(dev, param, NULL); - - baudrate = simple_strtoul(val, NULL, 10); - if (cdev->f_active) { printf("## Switch baudrate to %d bps and press ENTER ...\n", - baudrate); + cdev->baudrate); mdelay(50); - cdev->setbrg(cdev, baudrate); + cdev->setbrg(cdev, cdev->baudrate); mdelay(50); do { c = getc(); } while (c != '\r' && c != '\n'); } else - cdev->setbrg(cdev, baudrate); - - sprintf(baudstr, "%d", baudrate); - dev_param_set_generic(dev, param, baudstr); + cdev->setbrg(cdev, cdev->baudrate); return 0; } @@ -155,8 +144,9 @@ int console_register(struct console_device *newcdev) platform_device_register(dev); if (newcdev->setbrg) { - dev_add_param(dev, "baudrate", console_baudrate_set, NULL, 0); - dev_set_param(dev, "baudrate", __stringify(CONFIG_BAUDRATE)); + newcdev->baudrate = CONFIG_BAUDRATE; + dev_add_param_int(dev, "baudrate", console_baudrate_set, + NULL, &newcdev->baudrate, "%u", newcdev); } dev_add_param(dev, "active", console_std_set, NULL, 0); diff --git a/common/filetype.c b/common/filetype.c index 8652f1d7af..1ff3dd202a 100644 --- a/common/filetype.c +++ b/common/filetype.c @@ -151,6 +151,28 @@ enum filetype is_fat_or_mbr(const unsigned char *sector, unsigned long *bootsec) return filetype_mbr; } +enum filetype file_detect_partition_table(const void *_buf, size_t bufsize) +{ + const u8 *buf8 = _buf; + enum filetype type; + + if (bufsize < 512) + return filetype_unknown; + + /* + * EFI GPT need to be detected before MBR otherwise + * we will detect a MBR + */ + if (bufsize >= 520 && is_gpt_valid(buf8)) + return filetype_gpt; + + type = is_fat_or_mbr(buf8, NULL); + if (type != filetype_unknown) + return type; + + return filetype_unknown; +} + enum filetype file_detect_type(const void *_buf, size_t bufsize) { const u32 *buf = _buf; @@ -204,21 +226,11 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize) if (bufsize < 512) return filetype_unknown; - /* - * EFI GPT need to be detected before MBR otherwise - * we will detect a MBR - */ - if (bufsize >= 520 && is_gpt_valid(buf8)) - return filetype_gpt; - - type = is_fat_or_mbr(buf8, NULL); + type = file_detect_partition_table(_buf, bufsize); if (type != filetype_unknown) return type; - if (bufsize < 1536) - return filetype_unknown; - - if (buf16[512 + 28] == le16_to_cpu(0xef53)) + if (bufsize >= 1536 && buf16[512 + 28] == le16_to_cpu(0xef53)) return filetype_ext; return filetype_unknown; diff --git a/common/memory_display.c b/common/memory_display.c new file mode 100644 index 0000000000..eb188e1d79 --- /dev/null +++ b/common/memory_display.c @@ -0,0 +1,64 @@ +#include <common.h> + +#define DISP_LINE_LEN 16 + +int memory_display(char *addr, loff_t offs, unsigned nbytes, int size, int swab) +{ + ulong linebytes, i; + u_char *cp; + + /* Print the lines. + * + * We buffer all read data, so we can make sure data is read only + * once, and all accesses are with the specified bus width. + */ + do { + char linebuf[DISP_LINE_LEN]; + uint32_t *uip = (uint *)linebuf; + uint16_t *usp = (ushort *)linebuf; + uint8_t *ucp = (u_char *)linebuf; + unsigned count = 52; + + printf("%08llx:", offs); + linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes; + + for (i = 0; i < linebytes; i += size) { + if (size == 4) { + u32 res; + res = (*uip++ = *((uint *)addr)); + if (swab) + res = __swab32(res); + count -= printf(" %08x", res); + } else if (size == 2) { + u16 res; + res = (*usp++ = *((ushort *)addr)); + if (swab) + res = __swab16(res); + count -= printf(" %04x", res); + } else { + count -= printf(" %02x", (*ucp++ = *((u_char *)addr))); + } + addr += size; + offs += size; + } + + while (count--) + putchar(' '); + + cp = (uint8_t *)linebuf; + for (i = 0; i < linebytes; i++) { + if ((*cp < 0x20) || (*cp > 0x7e)) + putchar('.'); + else + printf("%c", *cp); + cp++; + } + + putchar('\n'); + nbytes -= linebytes; + if (ctrlc()) + return -EINTR; + } while (nbytes > 0); + + return 0; +} diff --git a/common/partitions.c b/common/partitions.c index dd25160602..683b2586e4 100644 --- a/common/partitions.c +++ b/common/partitions.c @@ -89,7 +89,7 @@ static struct partition_parser *partition_parser_get_by_filetype(uint8_t *buf) struct partition_parser *parser; /* first new partition table as EFI GPT */ - type = file_detect_type(buf, SECTOR_SIZE * 2); + type = file_detect_partition_table(buf, SECTOR_SIZE * 2); list_for_each_entry(parser, &partition_parser_list, list) { if (parser->type == type) @@ -100,7 +100,7 @@ static struct partition_parser *partition_parser_get_by_filetype(uint8_t *buf) * so if EFI GPT not enable take it as MBR * useful for compatibility */ - type = file_detect_type(buf, SECTOR_SIZE); + type = file_detect_partition_table(buf, SECTOR_SIZE); list_for_each_entry(parser, &partition_parser_list, list) { if (parser->type == type) diff --git a/defaultenv-2/base/bin/boot b/defaultenv-2/base/bin/boot index f7f460ea06..eed4b3c8b7 100644 --- a/defaultenv-2/base/bin/boot +++ b/defaultenv-2/base/bin/boot @@ -17,7 +17,7 @@ $0 [OPTIONS] [source]\n while getopt "vdhl" opt; do if [ ${opt} = v ]; then - BOOT_BOOTMOPTS="$BOOT_BOOTMOPTS -v" + BOOT_BOOTM_OPTS="$BOOT_BOOTM_OPTS -v" BOOT_VERBOSE=1 elif [ ${opt} = d ]; then BOOT_DRYRUN=1 diff --git a/defaultenv-2/base/bin/init b/defaultenv-2/base/bin/init index 6a658d137c..ca02ba6427 100644 --- a/defaultenv-2/base/bin/init +++ b/defaultenv-2/base/bin/init @@ -16,12 +16,6 @@ global editcmd=sedit [ -e /env/config-board ] && /env/config-board /env/config -if [ -e /env/menu ]; then - echo -e -n "\nHit m for menu or any other key to stop autoboot: " -else - echo -e -n "\nHit any key to stop autoboot: " -fi - # allow to stop the boot before execute the /env/init/* # but without waiting timeout -s -a -v key 0 @@ -34,6 +28,12 @@ for i in /env/init/*; do . $i done +if [ -e /env/menu ]; then + echo -e -n "\nHit m for menu or any other key to stop autoboot: " +else + echo -e -n "\nHit any key to stop autoboot: " +fi + timeout -a $global.autoboot_timeout -v key autoboot="$?" diff --git a/defaultenv-2/base/boot/net b/defaultenv-2/base/boot/net index 90c25aa147..05bb728fa1 100644 --- a/defaultenv-2/base/boot/net +++ b/defaultenv-2/base/boot/net @@ -8,7 +8,12 @@ fi path="/mnt/tftp" global.bootm.image="${path}/${global.user}-linux-${global.hostname}" -#global.bootm.oftree="${path}/${global.user}-oftree-${global.hostname}" + +oftree="${path}/${global.user}-oftree-${global.hostname}" +if [ -f "${oftree}" ]; then + global.bootm.oftree="$oftree" +fi + nfsroot="/home/${global.user}/nfsroot/${global.hostname}" bootargs-ip global.linux.bootargs.dyn.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp" diff --git a/drivers/Kconfig b/drivers/Kconfig index b213849af0..3a95e5140d 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -23,5 +23,6 @@ source "drivers/pwm/Kconfig" source "drivers/dma/Kconfig" source "drivers/gpio/Kconfig" source "drivers/w1/Kconfig" +source "drivers/pinctrl/Kconfig" endmenu diff --git a/drivers/Makefile b/drivers/Makefile index 03a10fbf2d..daf821c83c 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -22,3 +22,4 @@ obj-y += watchdog/ obj-y += gpio/ obj-$(CONFIG_OFTREE) += of/ obj-$(CONFIG_W1) += w1/ +obj-y += pinctrl/ diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index 7d7a6541ac..6106252264 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c @@ -153,14 +153,9 @@ int amba_device_add(struct amba_device *dev) if (ret) goto err_release; - if (IS_ENABLED(CONFIG_PARAMETER)) { - char str[16]; + dev_add_param_int_ro(&dev->dev, "periphid", dev->periphid, "0x%08x"); - sprintf(str, "0x%08x", dev->periphid); - dev_add_param_fixed(&dev->dev, "periphid", str); - } - - return ret; + return ret; err_release: release_region(res); return ret; diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index 42f2065a61..9830cc07a8 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig @@ -35,7 +35,6 @@ config DISK_ATA config DISK_AHCI bool "AHCI support" select DISK_ATA - select DISK_DRIVE config DISK_AHCI_IMX depends on ARCH_IMX diff --git a/drivers/ata/disk_ata_drive.c b/drivers/ata/disk_ata_drive.c index 6fe526acc8..2cff584d2a 100644 --- a/drivers/ata/disk_ata_drive.c +++ b/drivers/ata/disk_ata_drive.c @@ -325,20 +325,18 @@ on_error: return rc; } -static int ata_set_probe(struct device_d *class_dev, struct param_d *param, - const char *val) +static int ata_set_probe(struct param_d *param, void *priv) { - struct ata_port *port = container_of(class_dev, struct ata_port, class_dev); - int ret, probe; + struct ata_port *port = priv; + int ret; - if (port->initialized) { - dev_info(class_dev, "already initialized\n"); + if (!port->probe) return 0; - } - probe = !!simple_strtoul(val, NULL, 0); - if (!probe) + if (port->initialized) { + dev_info(&port->class_dev, "already initialized\n"); return 0; + } ret = ata_port_init(port); if (ret) @@ -346,7 +344,7 @@ static int ata_set_probe(struct device_d *class_dev, struct param_d *param, port->initialized = 1; - return dev_param_set_generic(class_dev, param, "1"); + return 0; } /** @@ -367,7 +365,8 @@ int ata_port_register(struct ata_port *port) if (ret) return ret; - dev_add_param(&port->class_dev, "probe", ata_set_probe, NULL, 0); + dev_add_param_bool(&port->class_dev, "probe", ata_set_probe, + NULL, &port->probe, port); return ret; } diff --git a/drivers/base/driver.c b/drivers/base/driver.c index 487f478d69..edd49b367f 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -31,6 +31,7 @@ #include <fs.h> #include <linux/list.h> #include <complete.h> +#include <pinctrl.h> LIST_HEAD(device_list); EXPORT_SYMBOL(device_list); @@ -79,6 +80,8 @@ int device_probe(struct device_d *dev) { int ret; + pinctrl_select_state_default(dev); + ret = dev->bus->probe(dev); if (ret) { dev_err(dev, "probe failed: %s\n", strerror(-ret)); diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 338b9e8dfe..256927eb4e 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -182,7 +182,7 @@ int clk_register_clkdev(struct clk *clk, const char *con_id, va_list ap; if (IS_ERR(clk)) - return PTR_ERR(clk); + return PTR_ERR(clk); va_start(ap, dev_fmt); cl = clkdev_alloc(clk, con_id, dev_fmt, ap); diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index d5e0ed1199..e976db4831 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -27,6 +27,9 @@ config GPIO_GENERIC_PLATFORM Say yes here to support basic platform memory-mapped GPIO controllers +config GPIO_IMX + def_bool ARCH_IMX + config GPIO_PL061 bool "PrimeCell PL061 GPIO support" depends on ARM_AMBA diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 5dcb6c8add..c1ec5bf772 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -1,7 +1,9 @@ -obj-$(CONFIG_GPIOLIB) += gpio.o +obj-$(CONFIG_GPIOLIB) += gpiolib.o + obj-$(CONFIG_GPIO_BCM2835) += gpio-bcm2835.o obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o +obj-$(CONFIG_GPIO_IMX) += gpio-imx.o obj-$(CONFIG_GPIO_PL061) += gpio-pl061.o obj-$(CONFIG_GPIO_STMPE) += gpio-stmpe.o obj-$(CONFIG_GPIO_TEGRA) += gpio-tegra.o diff --git a/arch/arm/mach-imx/gpio.c b/drivers/gpio/gpio-imx.c index 1bf4100964..1bf4100964 100644 --- a/arch/arm/mach-imx/gpio.c +++ b/drivers/gpio/gpio-imx.c diff --git a/drivers/gpio/gpio.c b/drivers/gpio/gpiolib.c index 6398268eae..6398268eae 100644 --- a/drivers/gpio/gpio.c +++ b/drivers/gpio/gpiolib.c diff --git a/drivers/input/qt1070.c b/drivers/input/qt1070.c index 43ea8823be..7f51da0e3d 100644 --- a/drivers/input/qt1070.c +++ b/drivers/input/qt1070.c @@ -239,10 +239,8 @@ static int qt1070_probe(struct device_d *dev) goto err; } - sprintf(buf, "0x%x", fw_version); - dev_add_param_fixed(dev, "fw_version", buf); - sprintf(buf, "0x%x", chip_id); - dev_add_param_fixed(dev, "chip_ip", buf); + dev_add_param_int_ro(dev, "fw_version", fw_version, "0x%x"); + dev_add_param_int_ro(dev, "chip_ip", chip_id, "0x%x"); memcpy(data->code, default_code, sizeof(int) * ARRAY_SIZE(default_code)); diff --git a/drivers/mci/atmel_mci.c b/drivers/mci/atmel_mci.c index f032403109..c5fd306a9a 100644 --- a/drivers/mci/atmel_mci.c +++ b/drivers/mci/atmel_mci.c @@ -262,11 +262,13 @@ static int atmci_read_response(struct atmel_mci *host, unsigned int stat) { struct mci_cmd *cmd = host->cmd; int i; - u32 *resp = (u32 *)cmd->response; + u32 *resp; if (!cmd) return 0; + resp = (u32 *)cmd->response; + if (stat & (ATMCI_RTOE | ATMCI_DTOE)) { dev_err(host->hw_dev, "command/data timeout\n"); return -ETIMEDOUT; diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c index 8c2695cded..f4fdac8e01 100644 --- a/drivers/mci/imx-esdhc.c +++ b/drivers/mci/imx-esdhc.c @@ -61,14 +61,11 @@ struct fsl_esdhc { u32 fevt; char reserved2[168]; u32 hostver; - char reserved3[780]; - u32 scr; }; struct fsl_esdhc_host { struct mci_host mci; struct fsl_esdhc __iomem *regs; - u32 no_snoop; unsigned long cur_clock; struct device_d *dev; struct clk *clk; @@ -454,10 +451,6 @@ static int esdhc_init(struct mci_host *mci, struct device_d *dev) int timeout = 1000; int ret = 0; - /* Enable cache snooping */ - if (host && !host->no_snoop) - esdhc_write32(®s->scr, 0x00000040); - /* Reset the entire host controller */ esdhc_write32(®s->sysctl, SYSCTL_RSTA); diff --git a/drivers/mci/imx.c b/drivers/mci/imx.c index 3d9bd0deb1..c98596434e 100644 --- a/drivers/mci/imx.c +++ b/drivers/mci/imx.c @@ -225,12 +225,13 @@ static int mxcmci_read_response(struct mxcmci_host *host, unsigned int stat) { struct mci_cmd *cmd = host->cmd; int i; - u32 a, b, c; - u32 *resp = (u32 *)cmd->response; + u32 a, b, c, *resp; if (!cmd) return 0; + resp = (u32 *)cmd->response; + if (stat & STATUS_TIME_OUT_RESP) { printf("CMD TIMEOUT\n"); return -ETIMEDOUT; diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c index aef5c690c6..90ac2a3748 100644 --- a/drivers/mci/mci-core.c +++ b/drivers/mci/mci-core.c @@ -34,6 +34,7 @@ #include <asm/byteorder.h> #include <block.h> #include <disks.h> +#include <linux/err.h> #define MAX_BUFFER_NUMBER 0xffffffff @@ -607,13 +608,17 @@ static void mci_set_clock(struct mci *mci, unsigned clock) { struct mci_host *host = mci->host; - /* check against any given limits */ + /* check against any given limits at the host's side */ if (clock > host->f_max) clock = host->f_max; if (clock < host->f_min) clock = host->f_min; + /* check against the limit at the card's side */ + if (mci->tran_speed != 0 && clock > mci->tran_speed) + clock = mci->tran_speed; + host->clock = clock; /* the new target frequency */ mci_set_ios(mci); } @@ -1375,7 +1380,8 @@ static int mci_card_probe(struct mci *mci) } mci_set_bus_width(mci, MMC_BUS_WIDTH_1); - mci_set_clock(mci, 1); /* set the lowest available clock */ + /* according to the SD card spec the detection can happen at 400 kHz */ + mci_set_clock(mci, 400000); /* reset the card */ rc = mci_go_idle(mci); @@ -1455,46 +1461,23 @@ on_error: * @param val "0" does nothing, a "1" will probe for a MCI card * @return 0 on success */ -static int mci_set_probe(struct device_d *mci_dev, struct param_d *param, - const char *val) +static int mci_set_probe(struct param_d *param, void *priv) { - struct mci *mci = mci_dev->priv; - int rc, probe; + struct mci *mci = priv; + int rc; + + if (!mci->probe) + return 0; rc = mci_check_if_already_initialized(mci); if (rc != 0) return 0; - if (!val) - return -EINVAL; - - probe = simple_strtoul(val, NULL, 0); - if (probe != 0) { - rc = mci_card_probe(mci); - if (rc != 0) - return rc; - } - - return dev_param_set_generic(mci_dev, param, val); -} - -/** - * Add parameter to the MCI device on demand - * @param mci_dev MCI device instance - * @return 0 on success - * - * This parameter is only available (or usefull) if MCI card probing is delayed - */ -static int add_mci_parameter(struct device_d *mci_dev) -{ - int rc; - - /* provide a 'probing right now' parameter for the user */ - rc = dev_add_param(mci_dev, "probe", mci_set_probe, NULL, 0); + rc = mci_card_probe(mci); if (rc != 0) return rc; - return dev_set_param(mci_dev, "probe", "0"); + return 0; } /** @@ -1517,8 +1500,10 @@ static int mci_probe(struct device_d *mci_dev) dev_info(mci->host->hw_dev, "registered as %s\n", dev_name(mci_dev)); - rc = add_mci_parameter(mci_dev); - if (rc != 0) { + mci->param_probe = dev_add_param_bool(mci_dev, "probe", + mci_set_probe, NULL, &mci->probe, mci); + + if (IS_ERR(mci->param_probe)) { dev_dbg(mci->mci_dev, "Failed to add 'probe' parameter to the MCI device\n"); goto on_error; } diff --git a/drivers/mci/mxs.c b/drivers/mci/mxs.c index 3657b3e496..c15461cf40 100644 --- a/drivers/mci/mxs.c +++ b/drivers/mci/mxs.c @@ -37,6 +37,7 @@ #include <clock.h> #include <io.h> #include <asm/bitops.h> +#include <mach/mxs.h> #include <mach/imx-regs.h> #include <mach/mci.h> #include <mach/clock.h> @@ -185,7 +186,7 @@ static int mxs_mci_read_data(struct mxs_mci_host *mxs_mci, void *buffer, unsigne if (length == 0) return 0; - return -EINVAL; + return -EIO; } @@ -222,7 +223,7 @@ static int mxs_mci_write_data(struct mxs_mci_host *mxs_mci, const void *buffer, if (length == 0) return 0; - return -EINVAL; + return -EIO; } /** @@ -446,19 +447,6 @@ static unsigned mxs_mci_setup_clock_speed(struct mxs_mci_host *mxs_mci, unsigned return ssp / div / rate; } -/** - * Reset the MCI engine (the hard way) - * @param hw_dev Host interface instance - * - * This will reset everything in all registers of this unit! (FIXME) - */ -static void mxs_mci_reset(struct mxs_mci_host *mxs_mci) -{ - writel(SSP_CTRL0_SFTRST, mxs_mci->regs + HW_SSP_CTRL0 + 8); - while (readl(mxs_mci->regs + HW_SSP_CTRL0) & SSP_CTRL0_SFTRST) - ; -} - /* ------------------------- MCI API -------------------------------------- */ /** @@ -475,7 +463,7 @@ static int mxs_mci_initialize(struct mci_host *host, struct device_d *mci_dev) writel(SSP_CTRL0_CLKGATE, mxs_mci->regs + HW_SSP_CTRL0 + 8); /* reset the unit */ - mxs_mci_reset(mxs_mci); + mxs_reset_block(mxs_mci->regs + HW_SSP_CTRL0, 0); /* restore the last settings */ mxs_mci_setup_timeout(mxs_mci, 0xffff); @@ -527,23 +515,23 @@ static void mxs_mci_set_ios(struct mci_host *host, struct mci_ios *ios) switch (ios->bus_width) { case MMC_BUS_WIDTH_8: mxs_mci->bus_width = 2; - host->bus_width = 8; /* 8 bit is possible */ + pr_debug("IO settings: changing bus width to 8 bits\n"); break; case MMC_BUS_WIDTH_4: mxs_mci->bus_width = 1; - host->bus_width = 4; /* 4 bit is possible */ + pr_debug("IO settings: changing bus width to 4 bits\n"); break; case MMC_BUS_WIDTH_1: mxs_mci->bus_width = 0; - host->bus_width = 1; /* 1 bit is possible */ + pr_debug("IO settings: changing bus width to 1 bit\n"); break; default: + pr_debug("IO settings: unsupported bus width!\n"); return; } mxs_mci->clock = mxs_mci_setup_clock_speed(mxs_mci, ios->clock); - pr_debug("IO settings: bus width=%d, frequency=%u Hz\n", host->bus_width, - mxs_mci->clock); + pr_debug("IO settings: frequency=%u Hz\n", mxs_mci->clock); } /* ----------------------------------------------------------------------- */ diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c index e28d9257a9..61744b69dc 100644 --- a/drivers/mtd/core.c +++ b/drivers/mtd/core.c @@ -286,7 +286,6 @@ static struct file_operations mtd_ops = { int add_mtd_device(struct mtd_info *mtd, char *devname) { - char str[16]; struct mtddev_hook *hook; if (!devname) @@ -305,14 +304,10 @@ int add_mtd_device(struct mtd_info *mtd, char *devname) mtd->cdev.mtd = mtd; if (IS_ENABLED(CONFIG_PARAMETER)) { - sprintf(str, "%u", mtd->size); - dev_add_param_fixed(&mtd->class_dev, "size", str); - sprintf(str, "%u", mtd->erasesize); - dev_add_param_fixed(&mtd->class_dev, "erasesize", str); - sprintf(str, "%u", mtd->writesize); - dev_add_param_fixed(&mtd->class_dev, "writesize", str); - sprintf(str, "%u", mtd->oobsize); - dev_add_param_fixed(&mtd->class_dev, "oobsize", str); + dev_add_param_int_ro(&mtd->class_dev, "size", mtd->size, "%u"); + dev_add_param_int_ro(&mtd->class_dev, "erasesize", mtd->erasesize, "%u"); + dev_add_param_int_ro(&mtd->class_dev, "writesize", mtd->oobsize, "%u"); + dev_add_param_int_ro(&mtd->class_dev, "oobsize", mtd->oobsize, "%u"); } devfs_create(&mtd->cdev); diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index fa10d9581e..e8103cf562 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -1179,16 +1179,15 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, return ERR_PTR(-ENODEV); } - /* Lookup the flash id */ - for (i = 0; nand_flash_ids[i].name != NULL; i++) { - if (dev_id == nand_flash_ids[i].id) { - type = &nand_flash_ids[i]; + if (!type) + type = nand_flash_ids; + + for (; type->name != NULL; type++) + if (dev_id == type->id) break; - } - } chip->onfi_version = 0; - if (!type) { + if (!type->name || !type->pagesize) { /* Check is chip is ONFI compliant */ ret = nand_flash_detect_onfi(mtd, chip, &busw); if (ret) @@ -1672,18 +1671,20 @@ EXPORT_SYMBOL(nand_scan_ident); EXPORT_SYMBOL(nand_scan_tail); EXPORT_SYMBOL(nand_release); -static int mtd_set_erasebad(struct device_d *dev, struct param_d *param, - const char *val) +static int mtd_set_erasebad(struct param_d *param, void *priv) { - struct mtd_info *mtd = container_of(dev, struct mtd_info, class_dev); - int erasebad; + struct mtd_info *mtd = priv; - erasebad = simple_strtoul(val, NULL, 0); + if (!mtd->p_allow_erasebad) { + mtd->allow_erasebad = false; + return 0; + } - if (erasebad && !mtd->allow_erasebad) - dev_warn(dev, "Allowing to erase bad blocks. This may be dangerous!\n"); + if (!mtd->allow_erasebad) + dev_warn(&mtd->class_dev, + "Allowing to erase bad blocks. This may be dangerous!\n"); - mtd->allow_erasebad = erasebad ? true : false; + mtd->allow_erasebad = true; return 0; } @@ -1714,8 +1715,8 @@ int add_mtd_nand_device(struct mtd_info *mtd, char *devname) return ret; if (IS_ENABLED(CONFIG_NAND_ALLOW_ERASE_BAD)) - dev_add_param(&mtd->class_dev, "erasebad", mtd_set_erasebad, - NULL, 0); + dev_add_param_bool(&mtd->class_dev, "erasebad", mtd_set_erasebad, + NULL, &mtd->p_allow_erasebad, mtd); dev_add_param(&mtd->class_dev, "bbt", NULL, mtd_get_bbt_type, 0); diff --git a/drivers/mtd/nand/nand_ids.c b/drivers/mtd/nand/nand_ids.c index 72593d44a8..4f8fb021a9 100644 --- a/drivers/mtd/nand/nand_ids.c +++ b/drivers/mtd/nand/nand_ids.c @@ -178,7 +178,9 @@ struct nand_manufacturers nand_manuf_ids[] = { {NAND_MFR_STMICRO, __NANDSTR("ST Micro")}, {NAND_MFR_HYNIX, __NANDSTR("Hynix")}, {NAND_MFR_MICRON, __NANDSTR("Micron")}, - {NAND_MFR_AMD, __NANDSTR("AMD")}, + {NAND_MFR_AMD, __NANDSTR("AMD/Spansion")}, + {NAND_MFR_MACRONIX, __NANDSTR("Macronix")}, + {NAND_MFR_EON, __NANDSTR("Eon")}, {0x0, "Unknown"} }; diff --git a/drivers/mtd/nand/nand_imx_bbm.c b/drivers/mtd/nand/nand_imx_bbm.c index 03961a0fb3..135d74e664 100644 --- a/drivers/mtd/nand/nand_imx_bbm.c +++ b/drivers/mtd/nand/nand_imx_bbm.c @@ -91,7 +91,7 @@ static void *create_bbt(struct mtd_info *mtd) buf = malloc(mtd->writesize); if (!buf) { ret = -ENOMEM; - goto out; + goto out2; } numblocks = mtd->size >> (chip->bbt_erase_shift - 1); @@ -99,7 +99,7 @@ static void *create_bbt(struct mtd_info *mtd) for (i = 0; i < numblocks;) { ret = checkbad(mtd, from, buf); if (ret < 0) - goto out; + goto out1; if (ret) { bbt[i >> 3] |= 0x03 << (i & 0x6); @@ -112,8 +112,11 @@ static void *create_bbt(struct mtd_info *mtd) } return bbt; -out: + +out1: free(buf); +out2: + free(bbt); return ERR_PTR(ret); } diff --git a/drivers/net/ksz8864rmn.c b/drivers/net/ksz8864rmn.c index af3c12489c..ec3e9f78ab 100644 --- a/drivers/net/ksz8864rmn.c +++ b/drivers/net/ksz8864rmn.c @@ -49,6 +49,7 @@ struct micrel_switch_priv { struct cdev cdev; struct spi_device *spi; + unsigned int p_enable; }; static int micrel_switch_read_reg(struct spi_device *spi, uint8_t reg) @@ -78,27 +79,15 @@ static void micrel_switch_write_reg(struct spi_device *spi, uint8_t reg, uint8_t spi_write_then_read(spi, tx, 3, NULL, 0); } -static int micrel_switch_enable_set(struct device_d *dev, struct param_d *param, - const char *val) +static int micrel_switch_enable_set(struct param_d *param, void *_priv) { - struct spi_device *spi = (struct spi_device *)dev->type_data; - int enable; - char *new; + struct micrel_switch_priv *priv = _priv; + struct spi_device *spi = priv->spi; - if (!val) - return dev_param_set_generic(dev, param, NULL); - - enable = simple_strtoul(val, NULL, 0); - - if (enable) { + if (priv->p_enable) micrel_switch_write_reg(spi, REG_ID1, 1); - new = "1"; - } else { + else micrel_switch_write_reg(spi, REG_ID1, 0); - new = "0"; - } - - dev_param_set_generic(dev, param, new); return 0; } @@ -172,8 +161,11 @@ static int micrel_switch_probe(struct device_d *dev) priv->cdev.dev = dev; devfs_create(&priv->cdev); - dev_add_param(dev, "enable", micrel_switch_enable_set, NULL, 0); - dev_set_param(dev, "enable", "1"); + dev_add_param_bool(dev, "enable", micrel_switch_enable_set, + NULL, &priv->p_enable, priv); + + priv->p_enable = 1; + micrel_switch_write_reg(priv->spi, REG_ID1, 1); return 0; } diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index e1bb7b1235..6163a50652 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -152,7 +152,6 @@ static int mdio_bus_probe(struct device_d *_dev) struct phy_driver *drv = to_phy_driver(_dev->driver); int ret; - char str[16]; dev->attached_dev->phydev = dev; @@ -192,11 +191,8 @@ static int mdio_bus_probe(struct device_d *_dev) if ((dev->supported & SUPPORTED_Autoneg) == 0) dev->autoneg = AUTONEG_DISABLE; - sprintf(str, "%d", dev->addr); - dev_add_param_fixed(&dev->dev, "phy_addr", str); - - sprintf(str, "0x%08x", dev->phy_id); - dev_add_param_fixed(&dev->dev, "phy_id", str); + dev_add_param_int_ro(&dev->dev, "phy_addr", dev->addr, "%d"); + dev_add_param_int_ro(&dev->dev, "phy_id", dev->phy_id, "0x%08x"); dev->cdev.name = asprintf("phy%d", _dev->id); dev->cdev.size = 64; diff --git a/drivers/of/base.c b/drivers/of/base.c index d22031f32f..8383549821 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -579,6 +579,52 @@ int of_property_read_string(struct device_node *np, const char *propname, } EXPORT_SYMBOL_GPL(of_property_read_string); +/** + * of_property_read_string_index - Find and read a string from a multiple + * strings property. + * @np: device node from which the property value is to be read. + * @propname: name of the property to be searched. + * @index: index of the string in the list of strings + * @out_string: pointer to null terminated return string, modified only if + * return value is 0. + * + * Search for a property in a device tree node and retrieve a null + * terminated string value (pointer to data, not a copy) in the list of strings + * contained in that property. + * Returns 0 on success, -EINVAL if the property does not exist, -ENODATA if + * property does not have a value, and -EILSEQ if the string is not + * null-terminated within the length of the property data. + * + * The out_string pointer is modified only if a valid string can be decoded. + */ +int of_property_read_string_index(struct device_node *np, const char *propname, + int index, const char **output) +{ + struct property *prop = of_find_property(np, propname); + int i = 0; + size_t l = 0, total = 0; + const char *p; + + if (!prop) + return -EINVAL; + if (!prop->value) + return -ENODATA; + if (strnlen(prop->value, prop->length) >= prop->length) + return -EILSEQ; + + p = prop->value; + + for (i = 0; total < prop->length; total += l, p += l) { + l = strlen(p) + 1; + if (i++ == index) { + *output = p; + return 0; + } + } + return -ENODATA; +} +EXPORT_SYMBOL_GPL(of_property_read_string_index); + struct device_node *of_get_root_node(void) { return root_node; @@ -782,7 +828,7 @@ static struct device_d *add_of_platform_device(struct device_node *node) dev->id = DEVICE_ID_SINGLE; dev->resource = node->resource; - dev->num_resources = 1; + dev->num_resources = node->num_resource; dev->device_node = node; node->device = dev; @@ -856,45 +902,65 @@ int of_add_memory(struct device_node *node, bool dump) sprintf(str, "ram%d", r); - barebox_add_memory_bank(str, base, size); + barebox_add_memory_bank(str, base, size); if (dump) pr_info("%s: %s: 0x%llx@0x%llx\n", node->name, str, size, base); r++; - } + } return 0; } static int add_of_device_resource(struct device_node *node) { - struct property *reg; - u64 address, size; - struct resource *res; + u64 address = 0, size; + struct resource *res, *resp; struct device_d *dev; - phandle phandle; - int ret; - - ret = of_property_read_u32(node, "phandle", &phandle); - if (!ret) { - node->phandle = phandle; - list_add_tail(&node->phandles, &phandle_list); - } + const __be32 *endp, *reg; + const char *resname; + int na, nc, n_resources; + int ret, len, index; ret = of_add_memory(node, false); if (ret != -ENXIO) return ret; - reg = of_find_property(node, "reg"); + reg = of_get_property(node, "reg", &len); if (!reg) - return -ENODEV; - - address = of_translate_address(node, reg->value); - if (address == OF_BAD_ADDR) return -EINVAL; - size = be32_to_cpu(((u32 *)reg->value)[1]); + of_bus_count_cells(node, &na, &nc); + + n_resources = (len / sizeof(__be32)) / (na + nc); + + res = resp = xzalloc(sizeof(*res) * n_resources); + + endp = reg + (len / sizeof(__be32)); + + index = 0; + + while ((endp - reg) >= (na + nc)) { + address = of_translate_address(node, reg); + if (address == OF_BAD_ADDR) { + ret = -EINVAL; + goto err_free; + } + + reg += na; + size = dt_mem_next_cell(nc, ®); + + resp->start = address; + resp->end = address + size - 1; + resname = NULL; + of_property_read_string_index(node, "reg-names", index, &resname); + if (resname) + resp->name = xstrdup(resname); + resp->flags = IORESOURCE_MEM; + resp++; + index++; + } /* * A device may already be registered as platform_device. @@ -909,20 +975,22 @@ static int add_of_device_resource(struct device_node *node) node->device = dev; dev->device_node = node; node->resource = dev->resource; - return 0; + ret = 0; + goto err_free; } } - res = xzalloc(sizeof(*res)); - res->start = address; - res->end = address + size - 1; - res->flags = IORESOURCE_MEM; - node->resource = res; + node->num_resource = n_resources; add_of_device(node); return 0; + +err_free: + free(res); + + return ret; } void of_free(struct device_node *node) @@ -975,6 +1043,22 @@ static void __of_probe(struct device_node *node) __of_probe(n); } +static void __of_parse_phandles(struct device_node *node) +{ + struct device_node *n; + phandle phandle; + int ret; + + ret = of_property_read_u32(node, "phandle", &phandle); + if (!ret) { + node->phandle = phandle; + list_add_tail(&node->phandles, &phandle_list); + } + + list_for_each_entry(n, &node->children, parent_list) + __of_parse_phandles(n); +} + struct device_node *of_chosen; const char *of_model; @@ -991,6 +1075,7 @@ int of_probe(void) of_chosen = of_find_node_by_path(root_node, "/chosen"); of_property_read_string(root_node, "model", &of_model); + __of_parse_phandles(root_node); __of_probe(root_node); return 0; @@ -1078,6 +1163,10 @@ int of_device_is_stdout_path(struct device_d *dev) * * Add initrd properties to the devicetree, or, if end is 0, * delete them. + * + * Note that Linux interprets end differently than barebox. For Linux end points + * to the first address after the memory occupied by the image while barebox + * lets end pointing to the last occupied byte. */ int of_add_initrd(struct device_node *root, resource_size_t start, resource_size_t end) @@ -1092,7 +1181,7 @@ int of_add_initrd(struct device_node *root, resource_size_t start, if (end) { of_write_number(buf, start, 2); of_set_property(chosen, "linux,initrd-start", buf, 8, 1); - of_write_number(buf, end, 2); + of_write_number(buf, end + 1, 2); of_set_property(chosen, "linux,initrd-end", buf, 8, 1); } else { struct property *pp; diff --git a/drivers/of/gpio.c b/drivers/of/gpio.c index d4314f3e28..83b72c03f3 100644 --- a/drivers/of/gpio.c +++ b/drivers/of/gpio.c @@ -25,4 +25,3 @@ int of_get_named_gpio(struct device_node *np, return ret; } - diff --git a/drivers/of/partition.c b/drivers/of/partition.c index 6a57a6036e..2d70cf5353 100644 --- a/drivers/of/partition.c +++ b/drivers/of/partition.c @@ -21,9 +21,9 @@ #include <of.h> #include <malloc.h> #include <linux/mtd/mtd.h> +#include <nand.h> -int of_parse_partitions(const char *cdevname, - struct device_node *node) +int of_parse_partitions(struct cdev *cdev, struct device_node *node) { struct device_node *n; const char *partname; @@ -48,14 +48,17 @@ int of_parse_partitions(const char *cdevname, partname = of_get_property(n, "name", &len); name = (char *)partname; - debug("add partition: %s.%s 0x%08lx 0x%08lx\n", cdevname, partname, offset, size); + debug("add partition: %s.%s 0x%08lx 0x%08lx\n", cdev->name, partname, offset, size); if (of_get_property(n, "read-only", &len)) flags = DEVFS_PARTITION_READONLY; - filename = asprintf("%s.%s", cdevname, partname); + filename = asprintf("%s.%s", cdev->name, partname); - devfs_add_partition(cdevname, offset, size, flags, filename); + devfs_add_partition(cdev->name, offset, size, flags, filename); + + if (cdev->mtd && cdev->mtd->type == MTD_NANDFLASH) + dev_add_bb_dev(filename, NULL); free(filename); } diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig new file mode 100644 index 0000000000..e6aee50a5f --- /dev/null +++ b/drivers/pinctrl/Kconfig @@ -0,0 +1,28 @@ +menu "Pin controllers" + +config PINCTRL + bool "Pin controller core support" + depends on OFDEVICE + help + Pincontrollers allow to setup the iomux unit of SoCs. The pin + controller core is needed when pin muxing shall be configured + from the devicetree. Legacy drivers here may not need this core + support but instead provide their own SoC specific APIs + +config PINCTRL_IMX_IOMUX_V1 + bool "i.MX iomux v1" + help + This iomux controller is found on i.MX1,21,27. + +config PINCTRL_IMX_IOMUX_V2 + bool "i.MX iomux v2" + help + This iomux controller is found on i.MX31. + +config PINCTRL_IMX_IOMUX_V3 + select PINCTRL if OFDEVICE + bool "i.MX iomux v3" + help + This iomux controller is found on i.MX25,35,51,53,6. + +endmenu diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile new file mode 100644 index 0000000000..e9272d0fb0 --- /dev/null +++ b/drivers/pinctrl/Makefile @@ -0,0 +1,4 @@ +obj-$(CONFIG_PINCTRL) += pinctrl.o +obj-$(CONFIG_PINCTRL_IMX_IOMUX_V1) += imx-iomux-v1.o +obj-$(CONFIG_PINCTRL_IMX_IOMUX_V2) += imx-iomux-v2.o +obj-$(CONFIG_PINCTRL_IMX_IOMUX_V3) += imx-iomux-v3.o diff --git a/arch/arm/mach-imx/iomux-v1.c b/drivers/pinctrl/imx-iomux-v1.c index f8f90615c6..f8f90615c6 100644 --- a/arch/arm/mach-imx/iomux-v1.c +++ b/drivers/pinctrl/imx-iomux-v1.c diff --git a/arch/arm/mach-imx/iomux-v2.c b/drivers/pinctrl/imx-iomux-v2.c index cef0340909..cef0340909 100644 --- a/arch/arm/mach-imx/iomux-v2.c +++ b/drivers/pinctrl/imx-iomux-v2.c diff --git a/drivers/pinctrl/imx-iomux-v3.c b/drivers/pinctrl/imx-iomux-v3.c new file mode 100644 index 0000000000..3ff3c1571d --- /dev/null +++ b/drivers/pinctrl/imx-iomux-v3.c @@ -0,0 +1,212 @@ +/* + * imx-iomux-v3.c - i.MX iomux-v3 pinctrl support + * + * Copyright (c) 2013 Sascha Hauer <s.hauer@pengutronix.de> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * 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 <common.h> +#include <init.h> +#include <io.h> +#include <pinctrl.h> +#include <malloc.h> +#include <mach/iomux-v3.h> + +struct imx_iomux_v3 { + void __iomem *base; + struct pinctrl_device pinctrl; +}; + +static void __iomem *iomuxv3_base; +static struct device_d *iomuxv3_dev; + +static void imx_iomuxv3_setup_single(void __iomem *base, struct device_d *dev, + u32 mux_reg, u32 conf_reg, u32 input_reg, + u32 mux_val, u32 conf_val, u32 input_val) +{ + dev_dbg(dev, + "mux: 0x%08x -> 0x%04x, conf: 0x%08x -> 0x%04x input: 0x%08x -> 0x%04x\n", + mux_val, mux_reg, conf_val, conf_reg, input_val, input_reg); + + if (mux_reg) + writel(mux_val, base + mux_reg); + if (conf_reg) + writel(conf_val, base + conf_reg); + if (input_reg) + writel(input_val, base + input_reg); +} + +/* + * configures a single pad in the iomuxer + */ +int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t pad) +{ + u32 mux_reg = (pad & MUX_CTRL_OFS_MASK) >> MUX_CTRL_OFS_SHIFT; + u32 mux_val = (pad & MUX_MODE_MASK) >> MUX_MODE_SHIFT; + u32 input_reg = (pad & MUX_SEL_INPUT_OFS_MASK) >> MUX_SEL_INPUT_OFS_SHIFT; + u32 input_val = (pad & MUX_SEL_INPUT_MASK) >> MUX_SEL_INPUT_SHIFT; + u32 conf_reg = (pad & MUX_PAD_CTRL_OFS_MASK) >> MUX_PAD_CTRL_OFS_SHIFT; + u32 conf_val = (pad & MUX_PAD_CTRL_MASK) >> MUX_PAD_CTRL_SHIFT; + + if (!iomuxv3_base) + return -EINVAL; + + if (conf_val & NO_PAD_CTRL) + conf_reg = 0; + + imx_iomuxv3_setup_single(iomuxv3_base, iomuxv3_dev, + mux_reg, conf_reg, input_reg, + mux_val, conf_val, input_val); + + return 0; +} +EXPORT_SYMBOL(mxc_iomux_v3_setup_pad); + + +int mxc_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t *pad_list, unsigned count) +{ + iomux_v3_cfg_t *p = pad_list; + int i; + int ret; + + for (i = 0; i < count; i++) { + ret = mxc_iomux_v3_setup_pad(*p); + if (ret) + return ret; + p++; + } + return 0; +} +EXPORT_SYMBOL(mxc_iomux_v3_setup_multiple_pads); + +/* + * Each pin represented in fsl,pins consists of 5 u32 PIN_FUNC_ID and + * 1 u32 CONFIG, so 24 types in total for each pin. + */ +#define FSL_PIN_SIZE 24 + +#define IMX_DT_NO_PAD_CTL (1 << 31) +#define IMX_PAD_SION (1 << 30) + +#define IOMUXC_CONFIG_SION (0x1 << 4) + +static int imx_iomux_v3_set_state(struct pinctrl_device *pdev, struct device_node *np) +{ + struct imx_iomux_v3 *iomux = container_of(pdev, struct imx_iomux_v3, pinctrl); + const __be32 *list; + int npins, size, i; + + dev_dbg(iomux->pinctrl.dev, "set state: %s\n", np->full_name); + + list = of_get_property(np, "fsl,pins", &size); + if (!list) + return -EINVAL; + + + if (!size || size % FSL_PIN_SIZE) { + dev_err(iomux->pinctrl.dev, "Invalid fsl,pins property\n"); + return -EINVAL; + } + + npins = size / FSL_PIN_SIZE; + + for (i = 0; i < npins; i++) { + u32 mux_reg = be32_to_cpu(*list++); + u32 conf_reg = be32_to_cpu(*list++); + u32 input_reg = be32_to_cpu(*list++); + u32 mux_val = be32_to_cpu(*list++); + u32 input_val = be32_to_cpu(*list++); + u32 conf_val = be32_to_cpu(*list++); + + if (conf_val & IMX_PAD_SION) + mux_val |= IOMUXC_CONFIG_SION; + + if (conf_val & IMX_DT_NO_PAD_CTL) + conf_reg = 0; + + imx_iomuxv3_setup_single(iomux->base, iomux->pinctrl.dev, + mux_reg, conf_reg, input_reg, + mux_val, conf_val, input_val); + } + + return 0; +} + +static struct pinctrl_ops imx_iomux_v3_ops = { + .set_state = imx_iomux_v3_set_state, +}; + +static int imx_pinctrl_dt(struct device_d *dev, void __iomem *base) +{ + struct imx_iomux_v3 *iomux; + int ret; + + iomux = xzalloc(sizeof(*iomux)); + + iomux->base = base; + + iomux->pinctrl.dev = dev; + iomux->pinctrl.ops = &imx_iomux_v3_ops; + + ret = pinctrl_register(&iomux->pinctrl); + if (ret) + free(iomux); + + return ret; +} + +static int imx_iomux_v3_probe(struct device_d *dev) +{ + int ret = 0; + + if (iomuxv3_base) + return -EBUSY; + + iomuxv3_base = dev_request_mem_region(dev, 0); + iomuxv3_dev = dev; + + if (IS_ENABLED(CONFIG_PINCTRL)) + ret = imx_pinctrl_dt(dev, iomuxv3_base); + + return ret; +} + +static __maybe_unused struct of_device_id imx_iomux_v3_dt_ids[] = { + { + .compatible = "fsl,imx25-iomuxc", + }, { + .compatible = "fsl,imx35-iomuxc", + }, { + .compatible = "fsl,imx51-iomuxc", + }, { + .compatible = "fsl,imx53-iomuxc", + }, { + .compatible = "fsl,imx6q-iomuxc", + }, { + /* sentinel */ + } +}; + +static struct driver_d imx_iomux_v3_driver = { + .name = "imx-iomuxv3", + .probe = imx_iomux_v3_probe, + .of_compatible = DRV_OF_COMPAT(imx_iomux_v3_dt_ids), +}; + +static int imx_iomux_v3_init(void) +{ + return platform_driver_register(&imx_iomux_v3_driver); +} +postcore_initcall(imx_iomux_v3_init); diff --git a/drivers/pinctrl/pinctrl.c b/drivers/pinctrl/pinctrl.c new file mode 100644 index 0000000000..fa979a1b78 --- /dev/null +++ b/drivers/pinctrl/pinctrl.c @@ -0,0 +1,149 @@ +/* + * pinctrl.c - barebox pinctrl support + * + * Copyright (c) 2013 Sascha Hauer <s.hauer@pengutronix.de> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * 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 <common.h> +#include <malloc.h> +#include <pinctrl.h> + +static LIST_HEAD(pinctrl_list); + +static struct pinctrl_device *find_pinctrl(struct device_node *node) +{ + struct pinctrl_device *pdev; + + list_for_each_entry(pdev, &pinctrl_list, list) + if (pdev->node == node) + return pdev; + return NULL; +} + +static int pinctrl_config_one(struct device_node *np) +{ + struct pinctrl_device *pdev; + struct device_node *pinctrl_node = np; + + while (1) { + pinctrl_node = pinctrl_node->parent; + if (!pinctrl_node) + return -ENODEV; + pdev = find_pinctrl(pinctrl_node); + if (pdev) + break; + } + + return pdev->ops->set_state(pdev, np); +} + +int pinctrl_select_state(struct device_d *dev, const char *name) +{ + int state, ret; + char *propname; + struct property *prop; + const __be32 *list; + int size, config; + phandle phandle; + struct device_node *np_config, *np; + const char *statename; + + np = dev->device_node; + if (!np) + return 0; + + if (!of_find_property(np, "pinctrl-0")) + return 0; + + /* For each defined state ID */ + for (state = 0; ; state++) { + /* Retrieve the pinctrl-* property */ + propname = asprintf("pinctrl-%d", state); + prop = of_find_property(np, propname); + free(propname); + + if (!prop) { + ret = -ENODEV; + break; + } + + size = prop->length; + + list = prop->value; + size /= sizeof(*list); + + /* Determine whether pinctrl-names property names the state */ + ret = of_property_read_string_index(np, "pinctrl-names", + state, &statename); + /* + * If not, statename is just the integer state ID. But rather + * than dynamically allocate it and have to free it later, + * just point part way into the property name for the string. + */ + if (ret < 0) { + /* strlen("pinctrl-") == 8 */ + statename = prop->name + 8; + } + + if (strcmp(name, statename)) + continue; + + /* For every referenced pin configuration node in it */ + for (config = 0; config < size; config++) { + phandle = be32_to_cpup(list++); + + /* Look up the pin configuration node */ + np_config = of_find_node_by_phandle(phandle); + if (!np_config) { + pr_err("prop %s %s index %i invalid phandle\n", + np->full_name, prop->name, config); + ret = -EINVAL; + goto err; + } + + /* Parse the node */ + ret = pinctrl_config_one(np_config); + if (ret < 0) + goto err; + } + + return 0; + } +err: + return ret; +} + +int pinctrl_select_state_default(struct device_d *dev) +{ + return pinctrl_select_state(dev, "default"); +} + +int pinctrl_register(struct pinctrl_device *pdev) +{ + BUG_ON(!pdev->dev->device_node); + + list_add_tail(&pdev->list, &pinctrl_list); + + pdev->node = pdev->dev->device_node; + + pinctrl_select_state_default(pdev->dev); + + return 0; +} + +void pinctrl_unregister(struct pinctrl_device *pdev) +{ + list_del(&pdev->list); +} diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index 70ec5901a0..db7d260c00 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -18,6 +18,7 @@ #include <malloc.h> #include <pwm.h> #include <linux/list.h> +#include <linux/err.h> struct pwm_device { struct pwm_chip *chip; @@ -26,22 +27,14 @@ struct pwm_device { #define FLAG_ENABLED 1 struct list_head node; struct device_d *dev; + + unsigned int duty_ns; + unsigned int period_ns; + unsigned int p_enable; }; static LIST_HEAD(pwm_list); -static struct pwm_device *dev_to_pwm(struct device_d *dev) -{ - struct pwm_device *pwm; - - list_for_each_entry(pwm, &pwm_list, node) { - if (pwm->dev == dev) - return pwm; - } - - return NULL; -} - static struct pwm_device *_find_pwm(const char *devname) { struct pwm_device *pwm; @@ -54,61 +47,25 @@ static struct pwm_device *_find_pwm(const char *devname) return NULL; } -static int set_period_ns(struct device_d *dev, struct param_d *p, - const char *val) +static int set_duty_period_ns(struct param_d *p, void *priv) { - struct pwm_device *pwm = dev_to_pwm(dev); - int period_ns; + struct pwm_device *pwm = priv; - if (!val) - return dev_param_set_generic(dev, p, NULL); + pwm_config(pwm, pwm->chip->duty_ns, pwm->chip->period_ns); - period_ns = simple_strtoul(val, NULL, 0); - pwm_config(pwm, pwm->chip->duty_ns, period_ns); - return dev_param_set_generic(dev, p, val); -} - -static int set_duty_ns(struct device_d *dev, struct param_d *p, const char *val) -{ - struct pwm_device *pwm = dev_to_pwm(dev); - int duty_ns; - - if (!val) - return dev_param_set_generic(dev, p, NULL); - - duty_ns = simple_strtoul(val, NULL, 0); - pwm_config(pwm, duty_ns, pwm->chip->period_ns); - return dev_param_set_generic(dev, p, val); + return 0; } -static int set_enable(struct device_d *dev, struct param_d *p, const char *val) +static int set_enable(struct param_d *p, void *priv) { - struct pwm_device *pwm = dev_to_pwm(dev); - int enable; - - if (!val) - return dev_param_set_generic(dev, p, NULL); + struct pwm_device *pwm = priv; - enable = !!simple_strtoul(val, NULL, 0); - if (enable) + if (pwm->p_enable) pwm_enable(pwm); else pwm_disable(pwm); - return dev_param_set_generic(dev, p, enable ? "1" : "0"); -} -static int pwm_register_vars(struct device_d *dev) -{ - int ret; - - ret = dev_add_param(dev, "duty_ns", set_duty_ns, NULL, 0); - if (!ret) - ret = dev_add_param(dev, "period_ns", set_period_ns, NULL, 0); - if (!ret) - ret = dev_add_param(dev, "enable", set_enable, NULL, 0); - if (!ret) - ret = dev_set_param(dev, "enable", 0); - return ret; + return 0; } /** @@ -121,7 +78,7 @@ static int pwm_register_vars(struct device_d *dev) int pwmchip_add(struct pwm_chip *chip, struct device_d *dev) { struct pwm_device *pwm; - int ret = 0; + struct param_d *p; if (_find_pwm(chip->devname)) return -EBUSY; @@ -131,9 +88,23 @@ int pwmchip_add(struct pwm_chip *chip, struct device_d *dev) pwm->dev = dev; list_add_tail(&pwm->node, &pwm_list); - pwm_register_vars(dev); - return ret; + p = dev_add_param_int(dev, "duty_ns", set_duty_period_ns, + NULL, &pwm->chip->duty_ns, "%u", pwm); + if (IS_ERR(p)) + return PTR_ERR(p); + + p = dev_add_param_int(dev, "period_ns", set_duty_period_ns, + NULL, &pwm->chip->period_ns, "%u", pwm); + if (IS_ERR(p)) + return PTR_ERR(p); + + p = dev_add_param_bool(dev, "enable", set_enable, + NULL, &pwm->p_enable, pwm); + if (IS_ERR(p)) + return PTR_ERR(p); + + return 0; } EXPORT_SYMBOL_GPL(pwmchip_add); diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index a813be5ca4..9a0723a2ed 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -439,19 +439,20 @@ static int usb_new_device(struct usb_device *dev) print_usb_device(dev); register_device(&dev->dev); - sprintf(str, "%d", dev->descriptor->iManufacturer); - dev_add_param_fixed(&dev->dev, "iManufacturer", str); - sprintf(str, "%d", dev->descriptor->iProduct); - dev_add_param_fixed(&dev->dev, "iProduct", str); - sprintf(str, "%d", dev->descriptor->iSerialNumber); + dev_add_param_int_ro(&dev->dev, "iManufacturer", + dev->descriptor->iManufacturer, "%d"); + dev_add_param_int_ro(&dev->dev, "iProduct", + dev->descriptor->iProduct, "%d"); + dev_add_param_int_ro(&dev->dev, "iSerialNumber", + dev->descriptor->iSerialNumber, "%d"); dev_add_param_fixed(&dev->dev, "iSerialNumber", str); dev_add_param_fixed(&dev->dev, "Manufacturer", dev->mf); dev_add_param_fixed(&dev->dev, "Product", dev->prod); dev_add_param_fixed(&dev->dev, "SerialNumber", dev->serial); - sprintf(str, "%04x", le16_to_cpu(dev->descriptor->idVendor)); - dev_add_param_fixed(&dev->dev, "idVendor", str); - sprintf(str, "%04x", le16_to_cpu(dev->descriptor->idProduct)); - dev_add_param_fixed(&dev->dev, "idProduct", str); + dev_add_param_int_ro(&dev->dev, "idVendor", + le16_to_cpu(dev->descriptor->idVendor), "%04x"); + dev_add_param_int_ro(&dev->dev, "idProduct", + le16_to_cpu(dev->descriptor->idProduct), "%04x"); list_add_tail(&dev->list, &usb_device_list); err = 0; diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 917ec4d006..a11379c933 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c @@ -1316,17 +1316,9 @@ static struct at91_udc controller = { static void at91_udc_irq (void *_udc); -static void at91_update_vbus(struct at91_udc *udc, u32 value) +static int at91_udc_vbus_set(struct param_d *p, void *priv) { - if (value == udc->gpio_vbus_val) - return; - - if (value) - dev_set_param(udc->dev, "vbus", "1"); - else - dev_set_param(udc->dev, "vbus", "0"); - - udc->gpio_vbus_val = value; + return -EROFS; } int usb_gadget_poll(void) @@ -1340,11 +1332,10 @@ int usb_gadget_poll(void) value = gpio_get_value(udc->board.vbus_pin); value ^= udc->board.vbus_active_low; - if (!value) { - at91_update_vbus(udc, value); + udc->gpio_vbus_val = value; + + if (!value) return 0; - } - at91_update_vbus(udc, value); value = at91_udp_read(udc, AT91_UDP_ISR) & (~(AT91_UDP_SOFINT)); if (value) @@ -1516,8 +1507,8 @@ static int __init at91udc_probe(struct device_d *dev) udc->vbus = 1; } - dev_add_param(dev, "vbus", NULL, NULL, 0); - dev_set_param(dev, "vbus", "0"); + dev_add_param_bool(dev, "vbus", + at91_udc_vbus_set, NULL, &udc->gpio_vbus_val, udc); poller_register(&poller); diff --git a/drivers/video/fb.c b/drivers/video/fb.c index be2969540d..0e00cb7675 100644 --- a/drivers/video/fb.c +++ b/drivers/video/fb.c @@ -28,31 +28,22 @@ static int fb_ioctl(struct cdev* cdev, int req, void *data) return 0; } -static int fb_enable_set(struct device_d *dev, struct param_d *param, - const char *val) +static int fb_enable_set(struct param_d *param, void *priv) { - struct fb_info *info = dev->priv; + struct fb_info *info = priv; int enable; - char *new; - - if (!val) - return dev_param_set_generic(dev, param, NULL); - enable = simple_strtoul(val, NULL, 0); + enable = info->p_enable; - if (enable) { - if (!info->enabled) - info->fbops->fb_enable(info); - new = "1"; - } else { - if (info->enabled) - info->fbops->fb_disable(info); - new = "0"; - } + if (enable == info->enabled) + return 0; - dev_param_set_generic(dev, param, new); + if (enable) + info->fbops->fb_enable(info); + else + info->fbops->fb_disable(info); - info->enabled = !!enable; + info->enabled = enable; return 0; } @@ -165,8 +156,8 @@ static int fb_probe(struct device_d *dev) { struct fb_info *info = dev->priv; - dev_add_param(dev, "enable", fb_enable_set, NULL, 0); - dev_set_param(dev, "enable", "0"); + dev_add_param_bool(dev, "enable", fb_enable_set, NULL, + &info->p_enable, info); if (info->num_modes && (info->mode_list != NULL) && (info->fbops->fb_activate_var != NULL)) { diff --git a/drivers/video/imx-ipu-fb.c b/drivers/video/imx-ipu-fb.c index db8b8323b0..b2ed7237c7 100644 --- a/drivers/video/imx-ipu-fb.c +++ b/drivers/video/imx-ipu-fb.c @@ -39,6 +39,8 @@ struct ipu_fb_info { struct fb_info info; struct fb_info overlay; struct device_d *dev; + + unsigned int alpha; }; /* IPU DMA Controller channel definitions. */ @@ -914,27 +916,17 @@ static struct fb_ops ipu_fb_overlay_ops = { .fb_disable = ipu_fb_overlay_disable_controller, }; -static int sdc_alpha_set(struct device_d *dev, struct param_d *param, - const char *val) +static int sdc_alpha_set(struct param_d *param, void *priv) { - struct fb_info *info = dev->priv; + struct fb_info *info = priv; struct ipu_fb_info *fbi = info->priv; - int alpha; - char alphastr[16]; unsigned int tmp; - if (!val) - return dev_param_set_generic(dev, param, NULL); - - alpha = simple_strtoul(val, NULL, 0); - alpha &= 0xff; + if (fbi->alpha > 0xff) + fbi->alpha = 0xff; tmp = reg_read(fbi, SDC_GW_CTRL) & 0x00FFFFFFL; - reg_write(fbi, tmp | ((u32) alpha << 24), SDC_GW_CTRL); - - sprintf(alphastr, "%d", alpha); - - dev_param_set_generic(dev, param, alphastr); + reg_write(fbi, tmp | ((u32) fbi->alpha << 24), SDC_GW_CTRL); return 0; } @@ -968,8 +960,9 @@ static int sdc_fb_register_overlay(struct ipu_fb_info *fbi, void *fb) return ret; } - dev_add_param(&overlay->dev, "alpha", sdc_alpha_set, NULL, 0); - dev_set_param(&overlay->dev, "alpha", "0"); + dev_add_param_int(&overlay->dev, "alpha", sdc_alpha_set, + NULL, &fbi->alpha, "%u", overlay); + return 0; } diff --git a/drivers/video/imx.c b/drivers/video/imx.c index 736e8d08e2..6e2d8d6f73 100644 --- a/drivers/video/imx.c +++ b/drivers/video/imx.c @@ -158,6 +158,8 @@ struct imxfb_info { void (*enable)(int enable); + unsigned int alpha; + struct fb_info overlay; }; @@ -421,30 +423,20 @@ static struct fb_ops imxfb_overlay_ops = { .fb_disable = imxfb_overlay_disable_controller, }; -static int imxfb_alpha_set(struct device_d *dev, struct param_d *param, - const char *val) +static int imxfb_alpha_set(struct param_d *param, void *priv) { - struct fb_info *overlay = dev->priv; + struct fb_info *overlay = priv; struct imxfb_info *fbi = overlay->priv; - int alpha; - char alphastr[16]; unsigned int tmp; - if (!val) - return dev_param_set_generic(dev, param, NULL); - - alpha = simple_strtoul(val, NULL, 0); - alpha &= 0xff; + if (fbi->alpha > 0xff) + fbi->alpha = 0xff; tmp = readl(fbi->regs + LCDC_LGWCR); tmp &= ~LGWCR_GWAV(0xff); - tmp |= LGWCR_GWAV(alpha); + tmp |= LGWCR_GWAV(fbi->alpha); writel(tmp , fbi->regs + LCDC_LGWCR); - sprintf(alphastr, "%d", alpha); - - dev_param_set_generic(dev, param, alphastr); - return 0; } @@ -508,8 +500,8 @@ static int imxfb_register_overlay(struct imxfb_info *fbi, void *fb) return ret; } - dev_add_param(&overlay->dev, "alpha", imxfb_alpha_set, NULL, 0); - dev_set_param(&overlay->dev, "alpha", "0"); + dev_add_param_int(&overlay->dev, "alpha", imxfb_alpha_set, + NULL, &fbi->alpha, "%u", overlay); return 0; } diff --git a/drivers/watchdog/im28wd.c b/drivers/watchdog/im28wd.c index 96cfe9a4f4..6ae4cf832f 100644 --- a/drivers/watchdog/im28wd.c +++ b/drivers/watchdog/im28wd.c @@ -33,16 +33,89 @@ #define MXS_RTC_WATCHDOG 0x50 +/* HW_RTC_PERSISTENT0 - holds bits used to configure various hardware settings */ #define MXS_RTC_PERSISTENT0 0x60 + +/* FIXME */ +# define MXS_RTC_PERSISTENT0_SPARE_ANALOG (1 << 22) /* dubious meaning from inside the SoC's firmware ROM */ # define MXS_RTC_PERSISTENT0_EXT_RST (1 << 21) /* dubious meaning from inside the SoC's firmware ROM */ # define MXS_RTC_PERSISTENT0_THM_RST (1 << 20) - +/* reserved on i.MX28 */ +# define MXS_RTC_PERSISTENT0_RELEASE_GND (1 << 19) +# define MXS_RTC_PERSISTENT0_ENABLE_LRADC_PWRUP (1 << 18) +# define MXS_RTC_PERSISTENT0_AUTO_RESTART (1 << 17) +# define MXS_RTC_PERSISTENT0_DISABLE_PSWITCH (1 << 16) +# define MXS_RTC_PERSISTENT0_LOWERBIAS (1 << 14) +# define MXS_RTC_PERSISTENT0_DISABLE_XTALOK (1 << 13) +# define MXS_RTC_PERSISTENT0_MSEC_RES (1 << 8) +# define MXS_RTC_PERSISTENT0_ALARM_WAKE (1 << 7) +# define MXS_RTC_PERSISTENT0_XTAL32_FREQ (1 << 6) +# define MXS_RTC_PERSISTENT0_XTAL32KHZ_PWRUP (1 << 5) +# define MXS_RTC_PERSISTENT0_XTAL24MHZ_PWRUP (1 << 4) +# define MXS_RTC_PERSISTENT0_LCK_SECS (1 << 3) +# define MXS_RTC_PERSISTENT0_ALARM_EN (1 << 2) +# define MXS_RTC_PERSISTENT0_ALARM_WAKE_EN (1 << 1) +# define MXS_RTC_PERSISTENT0_CLOCKSOURCE (1 << 0) + +/* HW_RTC_PERSISTENT1 - holds bits related to the ROM and redundant boot handling */ #define MXS_RTC_PERSISTENT1 0x70 + + +/* + * some of the following bits are for error reporting from ROM to the chained + * firmware. It seems, if the error reporting bits are not cleared when the + * chained firmware is running, the next time the following rule is active: + * "Loader enters recovery mode if any non-USB boot mode has an error. + * Which results into a system that seems not to start anymore. + */ + /* dubious meaning from inside the SoC's firmware ROM */ # define MXS_RTC_PERSISTENT1_FORCE_UPDATER (1 << 31) +/* names are from the i.MX28 datasheet. Undocumented behaviour */ +# define MXS_RTC_PERSISTENT1_ENUMERATE_500MA_TWICE (1 << 12) +# define MXS_RTC_PERSISTENT1_USB_BOOT_PLAYER_MODE (1 << 11) +# define MXS_RTC_PERSISTENT1_SKIP_CHECKDISK (1 << 10) +# define MXS_RTC_PERSISTENT1_USB_LOW_POWER_MODE (1 << 9) +# define MXS_RTC_PERSISTENT1_OTG_HNP_BIT (1 << 8) +# define MXS_RTC_PERSISTENT1_OTG_ATL_ROLE_BIT (1 << 7) +/* + * a few undocumented bits + */ +# define MXS_RTC_PERSISTENT1_SD_INIT_SEQ_2_ENABLE (1 << 6) +# define MXS_RTC_PERSISTENT1_SD_CMD0_DISABLE (1 << 5) +# define MXS_RTC_PERSISTENT1_SD_INIT_SEQ_1_DISABLE (1 << 4) +/* + * If this bit is set, ROM puts the SD/MMC card in high-speed mode. + * If this bit is set, the ROM driver will use a maximum speed based on the + * results of device identification and limited by choices available in the + * SSP clock index. + */ +# define MXS_RTC_PERSISTENT1_SD_SPEED_ENABLE (1 << 3) +/* + * The NAND driver sets this bit to indicate to the SDK that the boot image + * has ECC errors that reached the warning threshold. The SDK regenerates the + * firmware by copying it from the backup image. The SDK clears this bit. + * This bit had change its meaning from i.XM23 to i.MX28. Refer section + * 35.8 "NAND Boot Mode" for further details in the i.MX23 RM. + */ +# define MXS_RTC_PERSISTENT1_NAND_SDK_BLOCK_REWRITE (1 << 2) +/* + * When this bit is set, ROM attempts to boot from the secondary image if the + * boot driver supports it. This bit is set by the ROM boot driver and cleared + * by the SDK after repair. + * If not reset, the ROM seems to continue to start from the secondary image + * which will fail forever if there is no secondary image + */ +# define MXS_RTC_PERSISTENT1_NAND_SECONDARY_BOOT (1 << 1) +/* + * When this bit is set, the ROM code forces the system to boot in recovery + * mode, regardless of the selected mode. The ROM clears the bit. + */ +# define MXS_RTC_PERSISTENT1_FORCE_RECOVERY (1 << 0) + #define MXS_RTC_DEBUG 0xc0 #define WDOG_TICK_RATE 1000 /* the watchdog uses a 1 kHz clock rate */ diff --git a/include/ata_drive.h b/include/ata_drive.h index 4f8b6c05fd..049082f0ca 100644 --- a/include/ata_drive.h +++ b/include/ata_drive.h @@ -95,6 +95,7 @@ struct ata_port { struct block_device blk; uint16_t *id; int initialized; + int probe; }; int ide_port_register(struct device_d *, struct ata_ioports *); diff --git a/include/common.h b/include/common.h index e559b94a71..59fcd35ac1 100644 --- a/include/common.h +++ b/include/common.h @@ -219,7 +219,12 @@ int run_shell(void); #define PAGE_ALIGN(s) (((s) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) #define PAGE_ALIGN_DOWN(x) ((x) & ~(PAGE_SIZE - 1)) -int memory_display(char *addr, loff_t offs, ulong nbytes, int size, int swab); +int memory_display(char *addr, loff_t offs, unsigned nbytes, int size, int swab); + +int mem_parse_options(int argc, char *argv[], char *optstr, int *mode, + char **sourcefile, char **destfile, int *swab); +int open_and_lseek(const char *filename, int mode, loff_t pos); +#define RW_BUF_SIZE (unsigned)4096 extern const char version_string[]; #ifdef CONFIG_BANNER diff --git a/include/console.h b/include/console.h index c45feb4785..72cf99f55b 100644 --- a/include/console.h +++ b/include/console.h @@ -42,6 +42,8 @@ struct console_device { unsigned char f_caps; unsigned char f_active; + + unsigned int baudrate; }; int console_register(struct console_device *cdev); diff --git a/include/fb.h b/include/fb.h index c5944184b1..23d6c6d025 100644 --- a/include/fb.h +++ b/include/fb.h @@ -102,6 +102,7 @@ struct fb_info { struct fb_bitfield transp; /* transparency */ int enabled; + int p_enable; }; int register_framebuffer(struct fb_info *info); diff --git a/include/filetype.h b/include/filetype.h index 78ca5d2043..ee777acf99 100644 --- a/include/filetype.h +++ b/include/filetype.h @@ -31,6 +31,7 @@ enum filetype { const char *file_type_to_string(enum filetype f); const char *file_type_to_short_string(enum filetype f); +enum filetype file_detect_partition_table(const void *_buf, size_t bufsize); enum filetype file_detect_type(const void *_buf, size_t bufsize); enum filetype file_name_detect_type(const char *filename); enum filetype is_fat_or_mbr(const unsigned char *sector, unsigned long *bootsec); diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 390f4b0767..df04030473 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -208,6 +208,7 @@ struct mtd_info { /* If true erasing bad blocks is allowed, this is set via a device parameter */ bool allow_erasebad; + int p_allow_erasebad; }; int mtd_erase(struct mtd_info *mtd, struct erase_info *instr); diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index dc141a5186..25bae631e5 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -500,15 +500,17 @@ struct nand_chip { /* * NAND Flash Manufacturer ID Codes */ -#define NAND_MFR_TOSHIBA 0x98 -#define NAND_MFR_SAMSUNG 0xec -#define NAND_MFR_FUJITSU 0x04 -#define NAND_MFR_NATIONAL 0x8f -#define NAND_MFR_RENESAS 0x07 -#define NAND_MFR_STMICRO 0x20 -#define NAND_MFR_HYNIX 0xad -#define NAND_MFR_MICRON 0x2c -#define NAND_MFR_AMD 0x01 +#define NAND_MFR_TOSHIBA 0x98 +#define NAND_MFR_SAMSUNG 0xec +#define NAND_MFR_FUJITSU 0x04 +#define NAND_MFR_NATIONAL 0x8f +#define NAND_MFR_RENESAS 0x07 +#define NAND_MFR_STMICRO 0x20 +#define NAND_MFR_HYNIX 0xad +#define NAND_MFR_MICRON 0x2c +#define NAND_MFR_AMD 0x01 +#define NAND_MFR_MACRONIX 0xc2 +#define NAND_MFR_EON 0x92 /** * struct nand_flash_dev - NAND Flash Device ID Structure diff --git a/include/mci.h b/include/mci.h index cf9582dbe3..eca48a52f4 100644 --- a/include/mci.h +++ b/include/mci.h @@ -328,6 +328,8 @@ struct mci { uint64_t capacity; /**< Card's data capacity in bytes */ int ready_for_use; /** true if already probed */ char *ext_csd; + int probe; + struct param_d *param_probe; }; int mci_register(struct mci_host*); diff --git a/include/net.h b/include/net.h index e4f6f86ad0..bb6b8fa281 100644 --- a/include/net.h +++ b/include/net.h @@ -52,6 +52,12 @@ struct eth_device { struct device_d *parent; struct list_head list; + + IPaddr_t ipaddr; + IPaddr_t serverip; + IPaddr_t netmask; + IPaddr_t gateway; + char ethaddr[6]; }; #define dev_to_edev(d) container_of(d, struct eth_device, dev) @@ -384,7 +390,6 @@ typedef void rx_handler_f(void *ctx, char *packet, unsigned int len); void eth_set_current(struct eth_device *eth); struct eth_device *eth_get_current(void); struct eth_device *eth_get_byname(char *name); -void net_update_env(void); /** * net_receive - Pass a received packet from an ethernet driver to the protocol stack diff --git a/include/of.h b/include/of.h index 94ccfd8739..4dcf37e140 100644 --- a/include/of.h +++ b/include/of.h @@ -26,6 +26,7 @@ struct device_node { struct list_head parent_list; struct list_head list; struct resource *resource; + int num_resource; struct device_d *device; struct list_head phandles; phandle phandle; @@ -160,6 +161,8 @@ void of_delete_property(struct property *pp); int of_property_read_string(struct device_node *np, const char *propname, const char **out_string); +int of_property_read_string_index(struct device_node *np, const char *propname, + int index, const char **output); int of_set_property(struct device_node *node, const char *p, const void *val, int len, int create); struct device_node *of_create_node(struct device_node *root, const char *path); @@ -167,9 +170,10 @@ struct device_node *of_create_node(struct device_node *root, const char *path); struct device_node *of_get_root_node(void); int of_set_root_node(struct device_node *); +struct cdev; + #ifdef CONFIG_OFTREE -int of_parse_partitions(const char *cdevname, - struct device_node *node); +int of_parse_partitions(struct cdev *cdev, struct device_node *node); int of_alias_get_id(struct device_node *np, const char *stem); int of_device_is_stdout_path(struct device_d *dev); @@ -177,7 +181,7 @@ const char *of_get_model(void); void *of_flatten_dtb(struct device_node *node); int of_add_memory(struct device_node *node, bool dump); #else -static inline int of_parse_partitions(const char *cdevname, +static inline int of_parse_partitions(struct cdev *cdev, struct device_node *node) { return -EINVAL; diff --git a/include/param.h b/include/param.h index 3a585cd193..4af2d09c4c 100644 --- a/include/param.h +++ b/include/param.h @@ -15,6 +15,8 @@ struct param_d { unsigned int flags; char *name; char *value; + struct device_d *dev; + void *driver_priv; struct list_head list; }; @@ -28,18 +30,33 @@ int dev_add_param(struct device_d *dev, const char *name, const char *(*get)(struct device_d *, struct param_d *p), unsigned long flags); +struct param_d *dev_add_param_int(struct device_d *dev, const char *name, + int (*set)(struct param_d *p, void *priv), + int (*get)(struct param_d *p, void *priv), + int *value, const char *format, void *priv); + +struct param_d *dev_add_param_bool(struct device_d *dev, const char *name, + int (*set)(struct param_d *p, void *priv), + int (*get)(struct param_d *p, void *priv), + int *value, void *priv); + +struct param_d *dev_add_param_int_ro(struct device_d *dev, const char *name, + int value, const char *format); + +struct param_d *dev_add_param_ip(struct device_d *dev, const char *name, + int (*set)(struct param_d *p, void *priv), + int (*get)(struct param_d *p, void *priv), + IPaddr_t *ip, void *priv); + int dev_add_param_fixed(struct device_d *dev, char *name, char *value); -void dev_remove_param(struct device_d *dev, char *name); +void dev_remove_param(struct param_d *p); void dev_remove_parameters(struct device_d *dev); int dev_param_set_generic(struct device_d *dev, struct param_d *p, const char *val); -/* Convenience functions to handle a parameter as an ip address */ -int dev_set_param_ip(struct device_d *dev, char *name, IPaddr_t ip); -IPaddr_t dev_get_param_ip(struct device_d *dev, char *name); #else static inline const char *dev_get_param(struct device_d *dev, const char *name) { @@ -64,31 +81,50 @@ static inline int dev_add_param(struct device_d *dev, char *name, return 0; } -static inline int dev_add_param_fixed(struct device_d *dev, char *name, char *value) +static inline struct param_d *dev_add_param_int(struct device_d *dev, const char *name, + int (*set)(struct param_d *p, void *priv), + int (*get)(struct param_d *p, void *priv), + int *value, const char *format, void *priv) { - return 0; + return NULL; } -static inline void dev_remove_param(struct device_d *dev, char *name) {} +static inline struct param_d *dev_add_param_bool(struct device_d *dev, const char *name, + int (*set)(struct param_d *p, void *priv), + int (*get)(struct param_d *p, void *priv), + int *value, void *priv) +{ + return NULL; +} -static inline void dev_remove_parameters(struct device_d *dev) {} +static inline struct param_d *dev_add_param_int_ro(struct device_d *dev, const char *name, + int value, const char *format) +{ + return NULL; +} -static inline int dev_param_set_generic(struct device_d *dev, struct param_d *p, - const char *val) +static inline struct param_d *dev_add_param_ip(struct device_d *dev, const char *name, + int (*set)(struct param_d *p, void *priv), + int (*get)(struct param_d *p, void *priv), + IPaddr_t *ip, void *priv) { - return 0; + return NULL; } -/* Convenience functions to handle a parameter as an ip address */ -static inline int dev_set_param_ip(struct device_d *dev, char *name, IPaddr_t ip) +static inline int dev_add_param_fixed(struct device_d *dev, char *name, char *value) { return 0; } -static inline IPaddr_t dev_get_param_ip(struct device_d *dev, char *name) + +static inline void dev_remove_param(struct param_d *p) {} + +static inline void dev_remove_parameters(struct device_d *dev) {} + +static inline int dev_param_set_generic(struct device_d *dev, struct param_d *p, + const char *val) { return 0; } #endif #endif /* PARAM_H */ - diff --git a/include/pinctrl.h b/include/pinctrl.h new file mode 100644 index 0000000000..7323f8b2f2 --- /dev/null +++ b/include/pinctrl.h @@ -0,0 +1,35 @@ +#ifndef PINCTRL_H +#define PINCTRL_H + +struct pinctrl_device; + +struct pinctrl_ops { + int (*set_state)(struct pinctrl_device *, struct device_node *); +}; + +struct pinctrl_device { + struct device_d *dev; + struct pinctrl_ops *ops; + struct list_head list; + struct device_node *node; +}; + +int pinctrl_register(struct pinctrl_device *pdev); +void pinctrl_unregister(struct pinctrl_device *pdev); + +#ifdef CONFIG_PINCTRL +int pinctrl_select_state(struct device_d *dev, const char *state); +int pinctrl_select_state_default(struct device_d *dev); +#else +static inline int pinctrl_select_state(struct device_d *dev, const char *state) +{ + return -ENODEV; +} + +static inline int pinctrl_select_state_default(struct device_d *dev) +{ + return -ENODEV; +} +#endif + +#endif /* PINCTRL_H */ diff --git a/include/usb/usb.h b/include/usb/usb.h index afccf706d7..b2700127f3 100644 --- a/include/usb/usb.h +++ b/include/usb/usb.h @@ -196,7 +196,6 @@ struct usb_driver { extern struct bus_type usb_bus_type; int usb_driver_register(struct usb_driver *); -int usb_driver_unregister(struct usb_driver *); struct usb_host { int (*init)(struct usb_host *); diff --git a/lib/copy_file.c b/lib/copy_file.c index 484b2ca725..ab3d845a5b 100644 --- a/lib/copy_file.c +++ b/lib/copy_file.c @@ -6,8 +6,6 @@ #include <libbb.h> #include <progress.h> -#define RW_BUF_SIZE (ulong)4096 - /** * @param[in] src FIXME * @param[out] dst FIXME diff --git a/lib/parameter.c b/lib/parameter.c index c00b82438d..e47e8b9148 100644 --- a/lib/parameter.c +++ b/lib/parameter.c @@ -27,6 +27,7 @@ #include <net.h> #include <malloc.h> #include <driver.h> +#include <linux/err.h> struct param_d *get_param_by_name(struct device_d *dev, const char *name) { @@ -58,23 +59,6 @@ const char *dev_get_param(struct device_d *dev, const char *name) return param->get(dev, param); } -#ifdef CONFIG_NET -IPaddr_t dev_get_param_ip(struct device_d *dev, char *name) -{ - IPaddr_t ip; - - if (string_to_ip(dev_get_param(dev, name), &ip)) - return 0; - - return ip; -} - -int dev_set_param_ip(struct device_d *dev, char *name, IPaddr_t ip) -{ - return dev_set_param(dev, name, ip_to_string(ip)); -} -#endif - /** * dev_set_param - set a parameter of a device to a new value * @param dev The device @@ -139,14 +123,13 @@ static const char *param_get_generic(struct device_d *dev, struct param_d *p) return p->value ? p->value : ""; } -static struct param_d *__dev_add_param(struct device_d *dev, const char *name, +static int __dev_add_param(struct param_d *param, struct device_d *dev, const char *name, int (*set)(struct device_d *dev, struct param_d *p, const char *val), const char *(*get)(struct device_d *dev, struct param_d *p), unsigned long flags) { - struct param_d *param; - - param = xzalloc(sizeof(*param)); + if (get_param_by_name(dev, name)) + return -EEXIST; if (set) param->set = set; @@ -159,9 +142,10 @@ static struct param_d *__dev_add_param(struct device_d *dev, const char *name, param->name = strdup(name); param->flags = flags; + param->dev = dev; list_add_tail(¶m->list, &dev->parameters); - return param; + return 0; } /** @@ -183,14 +167,15 @@ int dev_add_param(struct device_d *dev, const char *name, unsigned long flags) { struct param_d *param; + int ret; - param = get_param_by_name(dev, name); - if (param) - return -EEXIST; + param = xzalloc(sizeof(*param)); - param = __dev_add_param(dev, name, set, get, flags); + ret = __dev_add_param(param, dev, name, set, get, flags); + if (ret) + free(param); - return param ? 0 : -EINVAL; + return ret; } /** @@ -202,32 +187,271 @@ int dev_add_param(struct device_d *dev, const char *name, int dev_add_param_fixed(struct device_d *dev, char *name, char *value) { struct param_d *param; + int ret; - param = __dev_add_param(dev, name, NULL, NULL, PARAM_FLAG_RO); - if (!param) - return -EINVAL; + param = xzalloc(sizeof(*param)); + + ret = __dev_add_param(param, dev, name, NULL, NULL, PARAM_FLAG_RO); + if (ret) { + free(param); + return ret; + } param->value = strdup(value); return 0; } +struct param_int { + struct param_d param; + int *value; + const char *format; +#define PARAM_INT_FLAG_BOOL (1 << 0) + unsigned flags; + int (*set)(struct param_d *p, void *priv); + int (*get)(struct param_d *p, void *priv); +}; + +static inline struct param_int *to_param_int(struct param_d *p) +{ + return container_of(p, struct param_int, param); +} + +static int param_int_set(struct device_d *dev, struct param_d *p, const char *val) +{ + struct param_int *pi = to_param_int(p); + int value_save = *pi->value; + int ret; + + if (!val) + return -EINVAL; + + *pi->value = simple_strtol(val, NULL, 0); + + if (pi->flags & PARAM_INT_FLAG_BOOL) + *pi->value = !!*pi->value; + + if (!pi->set) + return 0; + + ret = pi->set(p, p->driver_priv); + if (ret) + *pi->value = value_save; + + return ret; +} + +static const char *param_int_get(struct device_d *dev, struct param_d *p) +{ + struct param_int *pi = to_param_int(p); + int ret; + + if (pi->get) { + ret = pi->get(p, p->driver_priv); + if (ret) + return NULL; + } + + free(p->value); + p->value = asprintf(pi->format, *pi->value); + + return p->value; +} + /** - * dev_remove_param - remove a parameter from a device and free its - * memory + * dev_add_param_int - add an integer parameter to a device * @param dev The device * @param name The name of the parameter + * @param set set function + * @param get get function + * @param value pointer to the integer containing the value of the parameter + * @param format the printf format used to print the value + * @param priv user private data, will be passed to get/set + * + * The get function can be used as a notifier when the variable is about + * to be read. + * The set function can be used as a notifer when the variable is about + * to be written. Can also be used to limit the value. */ -void dev_remove_param(struct device_d *dev, char *name) +struct param_d *dev_add_param_int(struct device_d *dev, const char *name, + int (*set)(struct param_d *p, void *priv), + int (*get)(struct param_d *p, void *priv), + int *value, const char *format, void *priv) { - struct param_d *p = get_param_by_name(dev, name); + struct param_int *pi; + struct param_d *p; + int ret; - if (p) { - p->set(dev, p, NULL); - list_del(&p->list); - free(p->name); - free(p); + pi = xzalloc(sizeof(*pi)); + pi->value = value; + pi->format = format; + pi->set = set; + pi->get = get; + p = &pi->param; + p->driver_priv = priv; + + ret = __dev_add_param(p, dev, name, param_int_set, param_int_get, 0); + if (ret) { + free(pi); + return ERR_PTR(ret); + } + + return &pi->param; +} + +/** + * dev_add_param_bool - add an boolean parameter to a device + * @param dev The device + * @param name The name of the parameter + * @param set set function + * @param get get function + * @param value pointer to the integer containing the value of the parameter + * @param priv user private data, will be passed to get/set + * + * The get function can be used as a notifier when the variable is about + * to be read. + * The set function can be used as a notifer when the variable is about + * to be written. Can also be used to limit the value. + */ +struct param_d *dev_add_param_bool(struct device_d *dev, const char *name, + int (*set)(struct param_d *p, void *priv), + int (*get)(struct param_d *p, void *priv), + int *value, void *priv) +{ + struct param_int *pi; + struct param_d *p; + + p = dev_add_param_int(dev, name, set, get, value, "%d", priv); + if (IS_ERR(p)) + return p; + + pi = to_param_int(p); + pi->flags |= PARAM_INT_FLAG_BOOL; + + return p; +} + +struct param_int_ro { + struct param_d param; + char *value; +}; + +/** + * dev_add_param_int_ro - add a read only integer parameter to a device + * @param dev The device + * @param name The name of the parameter + * @param value The value of the parameter + * @param format the printf format used to print the value + */ +struct param_d *dev_add_param_int_ro(struct device_d *dev, const char *name, + int value, const char *format) +{ + struct param_int *piro; + int ret; + + piro = xzalloc(sizeof(*piro)); + + ret = __dev_add_param(&piro->param, dev, name, NULL, NULL, 0); + if (ret) { + free(piro); + return ERR_PTR(ret); } + + piro->param.value = asprintf(format, value); + + return &piro->param; +} + +#ifdef CONFIG_NET +struct param_ip { + struct param_d param; + IPaddr_t *ip; + const char *format; + int (*set)(struct param_d *p, void *priv); + int (*get)(struct param_d *p, void *priv); +}; + +static inline struct param_ip *to_param_ip(struct param_d *p) +{ + return container_of(p, struct param_ip, param); +} + +static int param_ip_set(struct device_d *dev, struct param_d *p, const char *val) +{ + struct param_ip *pi = to_param_ip(p); + IPaddr_t ip_save = *pi->ip; + int ret; + + if (!val) + return -EINVAL; + + ret = string_to_ip(val, pi->ip); + if (ret) + return ret; + + if (!pi->set) + return 0; + + ret = pi->set(p, p->driver_priv); + if (ret) + *pi->ip = ip_save; + + return ret; +} + +static const char *param_ip_get(struct device_d *dev, struct param_d *p) +{ + struct param_ip *pi = to_param_ip(p); + int ret; + + if (pi->get) { + ret = pi->get(p, p->driver_priv); + if (ret) + return NULL; + } + + free(p->value); + p->value = xstrdup(ip_to_string(*pi->ip)); + + return p->value; +} + +struct param_d *dev_add_param_ip(struct device_d *dev, const char *name, + int (*set)(struct param_d *p, void *priv), + int (*get)(struct param_d *p, void *priv), + IPaddr_t *ip, void *priv) +{ + struct param_ip *pi; + int ret; + + pi = xzalloc(sizeof(*pi)); + pi->ip = ip; + pi->set = set; + pi->get = get; + pi->param.driver_priv = priv; + + ret = __dev_add_param(&pi->param, dev, name, + param_ip_set, param_ip_get, 0); + if (ret) { + free(pi); + return ERR_PTR(ret); + } + + return &pi->param; +} +#endif + +/** + * dev_remove_param - remove a parameter from a device and free its + * memory + * @param p The parameter + */ +void dev_remove_param(struct param_d *p) +{ + p->set(p->dev, p, NULL); + list_del(&p->list); + free(p->name); + free(p); } /** @@ -86,7 +86,6 @@ void eth_set_current(struct eth_device *eth) } eth_current = eth; - net_update_env(); } struct eth_device * eth_get_current(void) @@ -210,39 +209,16 @@ int eth_rx(void) static int eth_set_ethaddr(struct device_d *dev, struct param_d *param, const char *val) { struct eth_device *edev = dev_to_edev(dev); - u8 ethaddr[6]; - - if (!val) - return dev_param_set_generic(dev, param, NULL); - - if (string_to_ethaddr(val, ethaddr) < 0) - return -EINVAL; - - dev_param_set_generic(dev, param, val); - - edev->set_ethaddr(edev, ethaddr); - - if (edev == eth_current) - net_update_env(); - - return 0; -} - -static int eth_set_ipaddr(struct device_d *dev, struct param_d *param, const char *val) -{ - struct eth_device *edev = dev_to_edev(dev); - IPaddr_t ip; if (!val) return dev_param_set_generic(dev, param, NULL); - if (string_to_ip(val, &ip)) + if (string_to_ethaddr(val, edev->ethaddr) < 0) return -EINVAL; dev_param_set_generic(dev, param, val); - if (edev == eth_current) - net_update_env(); + edev->set_ethaddr(edev, edev->ethaddr); return 0; } @@ -267,11 +243,11 @@ int eth_register(struct eth_device *edev) register_device(&edev->dev); - dev_add_param(dev, "ipaddr", eth_set_ipaddr, NULL, 0); + dev_add_param_ip(dev, "ipaddr", NULL, NULL, &edev->ipaddr, edev); + dev_add_param_ip(dev, "serverip", NULL, NULL, &edev->serverip, edev); + dev_add_param_ip(dev, "gateway", NULL, NULL, &edev->gateway, edev); + dev_add_param_ip(dev, "netmask", NULL, NULL, &edev->netmask, edev); dev_add_param(dev, "ethaddr", eth_set_ethaddr, NULL, 0); - dev_add_param(dev, "gateway", eth_set_ipaddr, NULL, 0); - dev_add_param(dev, "netmask", eth_set_ipaddr, NULL, 0); - dev_add_param(dev, "serverip", eth_set_ipaddr, NULL, 0); if (edev->init) edev->init(edev); @@ -296,10 +272,8 @@ int eth_register(struct eth_device *edev) } } - if (!eth_current) { + if (!eth_current) eth_current = edev; - net_update_env(); - } return 0; } @@ -36,29 +36,9 @@ #include <linux/ctype.h> #include <linux/err.h> -static IPaddr_t net_netmask; /* Our subnet mask (0=unknown) */ -static IPaddr_t net_gateway; /* Our gateways IP address */ - -static unsigned char net_ether[6]; /* Our ethernet address */ -static IPaddr_t net_ip; /* Our IP addr (0 = unknown) */ -static IPaddr_t net_serverip; /* Our IP addr (0 = unknown) */ - unsigned char *NetRxPackets[PKTBUFSRX]; /* Receive packets */ static unsigned int net_ip_id; -void net_update_env(void) -{ - struct eth_device *edev = eth_get_current(); - - net_ip = dev_get_param_ip(&edev->dev, "ipaddr"); - net_serverip = dev_get_param_ip(&edev->dev, "serverip"); - net_gateway = dev_get_param_ip(&edev->dev, "gateway"); - net_netmask = dev_get_param_ip(&edev->dev, "netmask"); - - string_to_ethaddr(dev_get_param(&edev->dev, "ethaddr"), - net_ether); -} - int net_checksum_ok(unsigned char *ptr, int len) { return net_checksum(ptr, len) + 1; @@ -210,6 +190,7 @@ static void arp_handler(struct arprequest *arp) static int arp_request(IPaddr_t dest, unsigned char *ether) { + struct eth_device *edev = eth_get_current(); char *pkt; struct arprequest *arp; uint64_t arp_start; @@ -232,7 +213,7 @@ static int arp_request(IPaddr_t dest, unsigned char *ether) pr_debug("ARP broadcast\n"); memset(et->et_dest, 0xff, 6); - memcpy(et->et_src, net_ether, 6); + memcpy(et->et_src, edev->ethaddr, 6); et->et_protlen = htons(PROT_ARP); arp = (struct arprequest *)(pkt + ETHER_HDR_SIZE); @@ -243,15 +224,15 @@ static int arp_request(IPaddr_t dest, unsigned char *ether) arp->ar_pln = 4; arp->ar_op = htons(ARPOP_REQUEST); - memcpy(arp->ar_data, net_ether, 6); /* source ET addr */ - net_write_ip(arp->ar_data + 6, net_ip); /* source IP addr */ + memcpy(arp->ar_data, edev->ethaddr, 6); /* source ET addr */ + net_write_ip(arp->ar_data + 6, edev->ipaddr); /* source IP addr */ memset(arp->ar_data + 10, 0, 6); /* dest ET addr = 0 */ - if ((dest & net_netmask) != (net_ip & net_netmask)) { - if (!net_gateway) + if ((dest & edev->netmask) != (edev->ipaddr & edev->netmask)) { + if (!edev->gateway) arp_wait_ip = dest; else - arp_wait_ip = net_gateway; + arp_wait_ip = edev->gateway; } else { arp_wait_ip = dest; } @@ -310,44 +291,44 @@ static uint16_t net_udp_new_localport(void) IPaddr_t net_get_serverip(void) { - return net_serverip; + struct eth_device *edev = eth_get_current(); + + return edev->serverip; } void net_set_serverip(IPaddr_t ip) { struct eth_device *edev = eth_get_current(); - net_serverip = ip; - dev_set_param_ip(&edev->dev, "serverip", net_serverip); + edev->serverip = ip; } void net_set_ip(IPaddr_t ip) { struct eth_device *edev = eth_get_current(); - net_ip = ip; - dev_set_param_ip(&edev->dev, "ipaddr", net_ip); + edev->ipaddr = ip; } IPaddr_t net_get_ip(void) { - return net_ip; + struct eth_device *edev = eth_get_current(); + + return edev->ipaddr; } void net_set_netmask(IPaddr_t nm) { struct eth_device *edev = eth_get_current(); - net_netmask = nm; - dev_set_param_ip(&edev->dev, "netmask", net_netmask); + edev->netmask = nm; } void net_set_gateway(IPaddr_t gw) { struct eth_device *edev = eth_get_current(); - net_gateway = gw; - dev_set_param_ip(&edev->dev, "gateway", net_gateway); + edev->gateway = gw; } static LIST_HEAD(connection_list); @@ -362,16 +343,16 @@ static struct net_connection *net_new(IPaddr_t dest, rx_handler_f *handler, if (!edev) return ERR_PTR(-ENETDOWN); - if (!is_valid_ether_addr(net_ether)) { + if (!is_valid_ether_addr(edev->ethaddr)) { char str[sizeof("xx:xx:xx:xx:xx:xx")]; - random_ether_addr(net_ether); - ethaddr_to_string(net_ether, str); + random_ether_addr(edev->ethaddr); + ethaddr_to_string(edev->ethaddr, str); printf("warning: No MAC address set. Using random address %s\n", str); dev_set_param(&edev->dev, "ethaddr", str); } /* If we don't have an ip only broadcast is allowed */ - if (!net_ip && dest != 0xffffffff) + if (!edev->ipaddr && dest != 0xffffffff) return ERR_PTR(-ENETDOWN); con = xzalloc(sizeof(*con)); @@ -394,14 +375,14 @@ static struct net_connection *net_new(IPaddr_t dest, rx_handler_f *handler, } con->et->et_protlen = htons(PROT_IP); - memcpy(con->et->et_src, net_ether, 6); + memcpy(con->et->et_src, edev->ethaddr, 6); con->ip->hl_v = 0x45; con->ip->tos = 0; con->ip->frag_off = htons(0x4000); /* No fragmentation */; con->ip->ttl = 255; net_copy_ip(&con->ip->daddr, &dest); - net_copy_ip(&con->ip->saddr, &net_ip); + net_copy_ip(&con->ip->saddr, &edev->ipaddr); list_add_tail(&con->list, &connection_list); @@ -479,20 +460,21 @@ static int net_answer_arp(unsigned char *pkt, int len) { struct arprequest *arp = (struct arprequest *)(pkt + ETHER_HDR_SIZE); struct ethernet *et = (struct ethernet *)pkt; + struct eth_device *edev = eth_get_current(); unsigned char *packet; int ret; debug("%s\n", __func__); memcpy (et->et_dest, et->et_src, 6); - memcpy (et->et_src, net_ether, 6); + memcpy (et->et_src, edev->ethaddr, 6); et->et_protlen = htons(PROT_ARP); arp->ar_op = htons(ARPOP_REPLY); memcpy(&arp->ar_data[10], &arp->ar_data[0], 6); net_copy_ip(&arp->ar_data[16], &arp->ar_data[6]); - memcpy(&arp->ar_data[0], net_ether, 6); - net_copy_ip(&arp->ar_data[6], &net_ip); + memcpy(&arp->ar_data[0], edev->ethaddr, 6); + net_copy_ip(&arp->ar_data[6], &edev->ipaddr); packet = net_alloc_packet(); if (!packet) @@ -517,6 +499,7 @@ static void net_bad_packet(unsigned char *pkt, int len) static int net_handle_arp(unsigned char *pkt, int len) { + struct eth_device *edev = eth_get_current(); struct arprequest *arp; debug("%s: got arp\n", __func__); @@ -541,9 +524,9 @@ static int net_handle_arp(unsigned char *pkt, int len) goto bad; if (arp->ar_pln != 4) goto bad; - if (net_ip == 0) + if (edev->ipaddr == 0) return 0; - if (net_read_ip(&arp->ar_data[16]) != net_ip) + if (net_read_ip(&arp->ar_data[16]) != edev->ipaddr) return 0; switch (ntohs(arp->ar_op)) { @@ -600,6 +583,7 @@ static int net_handle_icmp(unsigned char *pkt, int len) static int net_handle_ip(unsigned char *pkt, int len) { struct iphdr *ip = (struct iphdr *)(pkt + ETHER_HDR_SIZE); + struct eth_device *edev = eth_get_current(); IPaddr_t tmp; debug("%s\n", __func__); @@ -619,7 +603,7 @@ static int net_handle_ip(unsigned char *pkt, int len) goto bad; tmp = net_read_ip(&ip->daddr); - if (net_ip && tmp != net_ip && tmp != 0xffffffff) + if (edev->ipaddr && tmp != edev->ipaddr && tmp != 0xffffffff) return 0; switch (ip->protocol) { diff --git a/net/netconsole.c b/net/netconsole.c index 960de8d437..99891941b7 100644 --- a/net/netconsole.c +++ b/net/netconsole.c @@ -43,7 +43,7 @@ struct nc_priv { int busy; struct net_connection *con; - uint16_t port; + unsigned int port; IPaddr_t ip; }; @@ -123,49 +123,10 @@ static void nc_putc(struct console_device *cdev, char c) priv->busy = 0; } -static int nc_port_set(struct device_d *dev, struct param_d *param, - const char *val) +static int nc_port_set(struct param_d *p, void *_priv) { - struct nc_priv *priv = g_priv; - char portstr[16]; - int port; - - if (!val) - dev_param_set_generic(dev, param, NULL); - - port = simple_strtoul(val, NULL, 10); - if (port > 65535) - return -EINVAL; - - priv->port = port; nc_init(); - sprintf(portstr, "%d", port); - dev_param_set_generic(dev, param, portstr); - - return 0; -} - -static int nc_remoteip_set(struct device_d *dev, struct param_d *param, - const char *val) -{ - struct nc_priv *priv = g_priv; - IPaddr_t ip; - int ret; - - if (!val) - dev_param_set_generic(dev, param, NULL); - - if (string_to_ip(val, &ip)) - return -EINVAL; - - priv->ip = ip; - ret = nc_init(); - if (ret) - return ret; - - dev_param_set_generic(dev, param, val); - return 0; } @@ -192,9 +153,10 @@ static int netconsole_init(void) return ret; } - dev_add_param(&cdev->class_dev, "ip", nc_remoteip_set, NULL, 0); - dev_add_param(&cdev->class_dev, "port", nc_port_set, NULL, 0); - dev_set_param(&cdev->class_dev, "port", "6666"); + priv->port = 6666; + + dev_add_param_ip(&cdev->class_dev, "ip", NULL, NULL, &priv->ip, NULL); + dev_add_param_int(&cdev->class_dev, "port", nc_port_set, NULL, &priv->port, "%u", NULL); pr_info("registered as %s%d\n", cdev->class_dev.name, cdev->class_dev.id); diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 0d94f982fa..e80926fa0b 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -209,7 +209,7 @@ our $typeTypedefs = qr{(?x: )}; our $logFunctions = qr{(?x: - printk| + printk|printf| pr_(debug|dbg|vdbg|devel|info|warning|err|notice|alert|crit|emerg|cont)| (dev|netdev|netif)_(printk|dbg|vdbg|info|warn|err|notice|alert|crit|emerg|WARN)| WARN| |