
On 22.02.19 18:52, Martyn Welch wrote:
Same post as some minutes ago but with correct sender, sorry.
From: Sjoerd Simons sjoerd.simons@collabora.co.uk
Add support for the Bosch Guardian board.
CPU : AM335X-GP rev 2.1 Model: Bosch AM335x Guardian I2C: ready DRAM: 256 MiB NAND: 512 MiB MMC: OMAP SD/MMC: 0
Signed-off-by: Sjoerd Simons sjoerd.simons@collabora.co.uk Signed-off-by: Martyn Welch martyn.welch@collabora.com
Changes in v2:
- Correct guard #ifdef naming in board config header
- Remove missed cruft from board files
arch/arm/Kconfig | 1 + arch/arm/dts/am335x-guardian-u-boot.dtsi | 66 +++ arch/arm/dts/am335x-guardian.dts | 511 +++++++++++++++++++++++ arch/arm/mach-omap2/am33xx/Kconfig | 7 + board/bosch/guardian/Kconfig | 15 + board/bosch/guardian/MAINTAINERS | 6 + board/bosch/guardian/Makefile | 12 + board/bosch/guardian/board.c | 186 +++++++++ board/bosch/guardian/board.h | 17 + board/bosch/guardian/mux.c | 99 +++++ configs/am335x_guardian_defconfig | 90 ++++ include/configs/am335x_guardian.h | 111 +++++ 12 files changed, 1121 insertions(+) create mode 100644 arch/arm/dts/am335x-guardian-u-boot.dtsi create mode 100644 arch/arm/dts/am335x-guardian.dts create mode 100644 board/bosch/guardian/Kconfig create mode 100644 board/bosch/guardian/MAINTAINERS create mode 100644 board/bosch/guardian/Makefile create mode 100644 board/bosch/guardian/board.c create mode 100644 board/bosch/guardian/board.h create mode 100644 board/bosch/guardian/mux.c create mode 100644 configs/am335x_guardian_defconfig create mode 100644 include/configs/am335x_guardian.h
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 455f06cfee..d2b3dce2da 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1524,6 +1524,7 @@ source "arch/arm/cpu/armv8/Kconfig" source "arch/arm/mach-imx/Kconfig"
source "board/bosch/shc/Kconfig" +source "board/bosch/guardian/Kconfig" source "board/CarMediaLab/flea3/Kconfig" source "board/Marvell/aspenite/Kconfig" source "board/Marvell/gplugd/Kconfig"
[...]
diff --git a/arch/arm/dts/am335x-guardian.dts b/arch/arm/dts/am335x-guardian.dts new file mode 100644 index 0000000000..d8652ab014 --- /dev/null +++ b/arch/arm/dts/am335x-guardian.dts @@ -0,0 +1,511 @@ +// SPDX-License-Identifier: GPL-2.0 +/*
- Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
- Copyright (C) 2018 Robert Bosch Power Tools GmbH
- */
+/dts-v1/;
+#include "am33xx.dtsi" +#include <dt-bindings/input/input.h> +#include <dt-bindings/interrupt-controller/irq.h>
+/ {
- model = "Bosch AM335x Guardian";
- compatible = "bosch,am335x-guardian", "ti,am33xx";
- chosen {
stdout-path = &uart0;
tick-timer = &timer2;
- };
- cpus {
cpu@0 {
cpu0-supply = <&dcdc2_reg>;
};
- };
- memory@80000000 {
device_type = "memory";
reg = <0x80000000 0x10000000>; /* 256 MB */
- };
- gpio_keys {
compatible = "gpio-keys";
#address-cells = <1>;
#size-cells = <0>;
The properties #address-cells and #size-cells can be removed as the only child node does not have a reg property.
pinctrl-names = "default";
pinctrl-0 = <&gpio_keys_pins>;
button21 {
label = "guardian-power-button";
linux,code = <KEY_POWER>;
gpios = <&gpio2 21 0>;
wakeup-source;
};
- };
- leds {
compatible = "gpio-leds";
pinctrl-names = "default";
pinctrl-0 = <&leds_pins>;
led1 {
label = "green:heartbeat";
gpios = <&gpio1 27 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "heartbeat";
default-state = "off";
};
led2 {
label = "green:mmc0";
gpios = <&gpio1 26 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "mmc0";
default-state = "off";
};
- };
[...]
diff --git a/board/bosch/guardian/board.c b/board/bosch/guardian/board.c new file mode 100644 index 0000000000..7f6f500535 --- /dev/null +++ b/board/bosch/guardian/board.c @@ -0,0 +1,186 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
- board.c
- Board functions for Bosch Guardian
- Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
- Copyright (C) 2018 Robert Bosch Power Tools GmbH
- */
+#include <common.h> +#include <errno.h> +#include <spl.h> +#include <asm/arch/cpu.h> +#include <asm/arch/hardware.h> +#include <asm/arch/omap.h> +#include <asm/arch/ddr_defs.h> +#include <asm/arch/clock.h> +#include <asm/arch/gpio.h> +#include <asm/arch/mmc_host_def.h> +#include <asm/arch/sys_proto.h> +#include <asm/arch/mem.h> +#include <asm/io.h> +#include <asm/emif.h> +#include <asm/gpio.h> +#include <dm.h> +#include <i2c.h> +#include <miiphy.h> +#include <cpsw.h> +#include <panel.h> +#include <power/tps65217.h> +#include <power/tps65910.h> +#include <environment.h> +#include <watchdog.h> +#include <environment.h> +#include "board.h"
The suggested order of include files is: <common.h> <others.h> <asm/...> <arch/arm/...> <linux/...> "local.h"
+DECLARE_GLOBAL_DATA_PTR;
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT +static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
+static const struct ddr_data ddr3_data = {
- .datardsratio0 = MT41K128M16JT125K_RD_DQS,
- .datawdsratio0 = MT41K128M16JT125K_WR_DQS,
- .datafwsratio0 = MT41K128M16JT125K_PHY_FIFO_WE,
- .datawrsratio0 = MT41K128M16JT125K_PHY_WR_DATA,
+};
+static const struct cmd_control ddr3_cmd_ctrl_data = {
- .cmd0csratio = MT41K128M16JT125K_RATIO,
- .cmd0iclkout = MT41K128M16JT125K_INVERT_CLKOUT,
- .cmd1csratio = MT41K128M16JT125K_RATIO,
- .cmd1iclkout = MT41K128M16JT125K_INVERT_CLKOUT,
- .cmd2csratio = MT41K128M16JT125K_RATIO,
- .cmd2iclkout = MT41K128M16JT125K_INVERT_CLKOUT,
+};
+static struct emif_regs ddr3_emif_reg_data = {
- .sdram_config = MT41K128M16JT125K_EMIF_SDCFG,
- .ref_ctrl = MT41K128M16JT125K_EMIF_SDREF,
- .sdram_tim1 = MT41K128M16JT125K_EMIF_TIM1,
- .sdram_tim2 = MT41K128M16JT125K_EMIF_TIM2,
- .sdram_tim3 = MT41K128M16JT125K_EMIF_TIM3,
- .zq_config = MT41K128M16JT125K_ZQ_CFG,
- .emif_ddr_phy_ctlr_1 = MT41K128M16JT125K_EMIF_READ_LATENCY,
+};
+#define OSC (V_OSCK / 1000000) +const struct dpll_params dpll_ddr = {
400, OSC - 1, 1, -1, -1, -1, -1};
+void am33xx_spl_board_init(void) +{
- int mpu_vdd;
- int usb_cur_lim;
- /* Get the frequency */
- dpll_mpu_opp100.m = am335x_get_efuse_mpu_max_freq(cdev);
- if (i2c_probe(TPS65217_CHIP_PM))
return;
- /*
* Increase USB current limit to 1300mA or 1800mA and set
* the MPU voltage controller as needed.
*/
- if (dpll_mpu_opp100.m == MPUPLL_M_1000) {
usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1800MA;
mpu_vdd = TPS65217_DCDC_VOLT_SEL_1325MV;
- } else {
usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1300MA;
mpu_vdd = TPS65217_DCDC_VOLT_SEL_1275MV;
- }
- if (tps65217_reg_write(TPS65217_PROT_LEVEL_NONE,
TPS65217_POWER_PATH,
usb_cur_lim,
TPS65217_USB_INPUT_CUR_LIMIT_MASK))
puts("tps65217_reg_write failure\n");
- /* Set DCDC3 (CORE) voltage to 1.125V */
- if (tps65217_voltage_update(TPS65217_DEFDCDC3,
TPS65217_DCDC_VOLT_SEL_1125MV)) {
puts("tps65217_voltage_update failure\n");
return;
- }
- /* Set CORE Frequencies to OPP100 */
- do_setup_dpll(&dpll_core_regs, &dpll_core_opp100);
- /* Set DCDC2 (MPU) voltage */
- if (tps65217_voltage_update(TPS65217_DEFDCDC2, mpu_vdd)) {
puts("tps65217_voltage_update failure\n");
return;
- }
- /*
* Set LDO3 to 1.8V and LDO4 to 3.3V
*/
- if (tps65217_reg_write(TPS65217_PROT_LEVEL_2,
TPS65217_DEFLS1,
TPS65217_LDO_VOLTAGE_OUT_1_8,
TPS65217_LDO_MASK))
puts("tps65217_reg_write failure\n");
- if (tps65217_reg_write(TPS65217_PROT_LEVEL_2,
TPS65217_DEFLS2,
TPS65217_LDO_VOLTAGE_OUT_3_3,
TPS65217_LDO_MASK))
puts("tps65217_reg_write failure\n");
- /* Set MPU Frequency to what we detected now that voltages are set */
- do_setup_dpll(&dpll_mpu_regs, &dpll_mpu_opp100);
+}
+const struct dpll_params *get_dpll_ddr_params(void) +{
- enable_i2c0_pin_mux();
- i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
- return &dpll_ddr;
+}
+void set_uart_mux_conf(void) +{
- enable_uart0_pin_mux();
+}
+void set_mux_conf_regs(void) +{
- enable_board_pin_mux();
+}
+const struct ctrl_ioregs ioregs = {
- .cm0ioctl = MT41K128M16JT125K_IOCTRL_VALUE,
- .cm1ioctl = MT41K128M16JT125K_IOCTRL_VALUE,
- .cm2ioctl = MT41K128M16JT125K_IOCTRL_VALUE,
- .dt0ioctl = MT41K128M16JT125K_IOCTRL_VALUE,
- .dt1ioctl = MT41K128M16JT125K_IOCTRL_VALUE,
+};
+void sdram_init(void) +{
- config_ddr(400, &ioregs,
&ddr3_data,
&ddr3_cmd_ctrl_data,
&ddr3_emif_reg_data, 0);
+} +#endif
+int board_init(void) +{ +#if defined(CONFIG_HW_WATCHDOG)
- hw_watchdog_init();
+#endif
- gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
+#ifdef CONFIG_NAND
- gpmc_init();
+#endif
- return 0;
+} diff --git a/board/bosch/guardian/board.h b/board/bosch/guardian/board.h new file mode 100644 index 0000000000..b301caf47f --- /dev/null +++ b/board/bosch/guardian/board.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/*
- board.h
- Board header for Bosch Guardian
- Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
- Copyright (C) 2018 Robert Bosch Power Tools GmbH
- */
+#ifndef _BOARD_H_ +#define _BOARD_H_
+void enable_uart0_pin_mux(void); +void enable_i2c0_pin_mux(void); +void enable_board_pin_mux(void); +#endif diff --git a/board/bosch/guardian/mux.c b/board/bosch/guardian/mux.c new file mode 100644 index 0000000000..93f40b8a02 --- /dev/null +++ b/board/bosch/guardian/mux.c @@ -0,0 +1,99 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
- mux.c
- Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
- Copyright (C) 2018 Robert Bosch Power Tools GmbH
- */
+#include <common.h> +#include <asm/arch/sys_proto.h> +#include <asm/arch/hardware.h> +#include <asm/arch/mux.h> +#include <asm/io.h> +#include <i2c.h> +#include "board.h"
Order of include files (same as above).
+static struct module_pin_mux uart0_pin_mux[] = {
- {OFFSET(uart0_rxd), (MODE(0) | PULLUP_EN | RXACTIVE)},
- {OFFSET(uart0_txd), (MODE(0) | PULLUDEN)},
- {-1},
+};
+static struct module_pin_mux i2c0_pin_mux[] = {
- {OFFSET(i2c0_sda), (MODE(0) | RXACTIVE | PULLUDEN | SLEWCTRL)},
- {OFFSET(i2c0_scl), (MODE(0) | RXACTIVE | PULLUDEN | SLEWCTRL)},
- {-1},
+};
+static struct module_pin_mux adc_voltages_en[] = {
- {OFFSET(mcasp0_ahclkx), (MODE(7) | PULLUP_EN)},
- {-1},
+};
+static struct module_pin_mux asp_power_en[] = {
- {OFFSET(mcasp0_aclkx), (MODE(7) | PULLUP_EN)},
- {-1},
+};
+static struct module_pin_mux switch_off_3v6_pin_mux[] = {
- {OFFSET(mii1_txd0), (MODE(7) | PULLUP_EN)},
- /*
* The uart1 lines are made floating inputs, based on the Guardian
* A2 Sample Power Supply Schematics
*/
- {OFFSET(uart1_rxd), (MODE(7) | PULLUDDIS)},
- {OFFSET(uart1_txd), (MODE(7) | PULLUDDIS)},
- {-1},
+};
+#ifdef CONFIG_NAND +static struct module_pin_mux nand_pin_mux[] = {
- {OFFSET(gpmc_ad0), (MODE(0) | PULLUDDIS | RXACTIVE)},
- {OFFSET(gpmc_ad1), (MODE(0) | PULLUDDIS | RXACTIVE)},
- {OFFSET(gpmc_ad2), (MODE(0) | PULLUDDIS | RXACTIVE)},
- {OFFSET(gpmc_ad3), (MODE(0) | PULLUDDIS | RXACTIVE)},
- {OFFSET(gpmc_ad4), (MODE(0) | PULLUDDIS | RXACTIVE)},
- {OFFSET(gpmc_ad5), (MODE(0) | PULLUDDIS | RXACTIVE)},
- {OFFSET(gpmc_ad6), (MODE(0) | PULLUDDIS | RXACTIVE)},
- {OFFSET(gpmc_ad7), (MODE(0) | PULLUDDIS | RXACTIVE)},
+#ifdef CONFIG_SYS_NAND_BUSWIDTH_16BIT
- {OFFSET(gpmc_ad8), (MODE(0) | PULLUDDIS | RXACTIVE)},
- {OFFSET(gpmc_ad9), (MODE(0) | PULLUDDIS | RXACTIVE)},
- {OFFSET(gpmc_ad10), (MODE(0) | PULLUDDIS | RXACTIVE)},
- {OFFSET(gpmc_ad11), (MODE(0) | PULLUDDIS | RXACTIVE)},
- {OFFSET(gpmc_ad12), (MODE(0) | PULLUDDIS | RXACTIVE)},
- {OFFSET(gpmc_ad13), (MODE(0) | PULLUDDIS | RXACTIVE)},
- {OFFSET(gpmc_ad14), (MODE(0) | PULLUDDIS | RXACTIVE)},
- {OFFSET(gpmc_ad15), (MODE(0) | PULLUDDIS | RXACTIVE)},
+#endif
- {OFFSET(gpmc_wait0), (MODE(0) | PULLUP_EN | RXACTIVE)},
- {OFFSET(gpmc_wpn), (MODE(7) | PULLUP_EN)},
- {OFFSET(gpmc_csn0), (MODE(0) | PULLUP_EN)},
- {OFFSET(gpmc_wen), (MODE(0) | PULLDOWN_EN)},
- {OFFSET(gpmc_oen_ren), (MODE(0) | PULLDOWN_EN)},
- {OFFSET(gpmc_advn_ale), (MODE(0) | PULLDOWN_EN)},
- {OFFSET(gpmc_be0n_cle), (MODE(0) | PULLDOWN_EN)},
- {-1},
+}; +#endif
+void enable_uart0_pin_mux(void) +{
- configure_module_pin_mux(uart0_pin_mux);
+}
+void enable_i2c0_pin_mux(void) +{
- configure_module_pin_mux(i2c0_pin_mux);
+}
+void enable_board_pin_mux(void) +{ +#ifdef CONFIG_NAND
- configure_module_pin_mux(nand_pin_mux);
+#endif
- configure_module_pin_mux(adc_voltages_en);
- configure_module_pin_mux(asp_power_en);
- configure_module_pin_mux(switch_off_3v6_pin_mux);
+}
regards, Felix