board/BuR/brxre1: convert do DM
authorHannes Schmelzer <hannes.schmelzer@br-automation.com>
Wed, 6 Feb 2019 12:25:59 +0000 (13:25 +0100)
committerTom Rini <trini@konsulko.com>
Tue, 19 Feb 2019 13:55:43 +0000 (08:55 -0500)
This commit converts the brxre1 board to DM,
for this we have todo following things:

- add a devicetree-file for this board
- drop all obsolete settings from board header-file
- use dm_i2c_xxx calls for read/write to the resetcontroller
- request gpios before operate them

Serues-cc: trini@konsulko.com
Signed-off-by: Hannes Schmelzer <hannes.schmelzer@br-automation.com>
arch/arm/dts/am335x-brxre1.dts [new file with mode: 0644]
board/BuR/brxre1/MAINTAINERS
board/BuR/brxre1/board.c
board/BuR/common/common.c
configs/brxre1_defconfig
include/configs/brxre1.h

diff --git a/arch/arm/dts/am335x-brxre1.dts b/arch/arm/dts/am335x-brxre1.dts
new file mode 100644 (file)
index 0000000..708407d
--- /dev/null
@@ -0,0 +1,371 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 B&R Industrial Automation GmbH
+ * http://www.br-automation.com
+ *
+ */
+/dts-v1/;
+
+#include "am33xx.dtsi"
+
+/ {
+       model = "BRXRE1 Panel";
+       compatible = "ti,am33xx";
+
+       fset: factory-settings {
+               bl-version      = "                                ";
+               order-no        = "                                ";
+               cpu-order-no    = "                                ";
+               hw-revision     = "                                ";
+               serial-no       = <0>;
+               device-id       = <0xE681>;
+               parent-id       = <0xE681>;
+               hw-variant      = <0x3>;
+               hw-platform     = <0x0>;
+               fram-offset     = <0x1000>;
+               fram-size       = <0x3000>;
+               cache-disable   = <0x0>;
+               cpu-clock       = <0x0>;
+       };
+       chosen {
+               #address-cells = <1>;
+               #size-cells = <1>;
+
+               bootargs = "console=ttyO0,115200 earlyprintk";
+               stdout-path = &uart0;
+
+               framebuffer: framebuffer@8fbe0000 {
+                       display = <&lcdscreen0>;
+                       compatible = "simple-framebuffer";
+                       status = "okay";
+                       reg = <0x8fbef000 (1024 * 600 * 4)>;
+                       width = <1024>;
+                       height = <600>;
+                       stride = <(1024 * 4)>;
+                       format = "a8r8g8b8";
+                       clocks = <&dpll_disp_m2_ck>, <&dpll_per_m2_ck>;
+               };
+       };
+
+       aliases {
+               fset = &fset;
+               mmc = &mmc2;
+               spi0 = &spi0;
+               spi1 = &spi1;
+               touch0 = &burtouch0;
+               screen0 = &lcdscreen0;
+       };
+
+       memory {
+               device_type = "memory";
+               reg = <0x80000000 0x10000000>; /* 256 MB */
+       };
+
+       panel {
+               compatible = "ti,tilcdc,panel";
+               status = "okay";
+       };
+
+       vmmcsd_fixed: fixedregulator@0 {
+               compatible = "regulator-fixed";
+               regulator-name = "vmmcsd_fixed";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+       };
+
+       lcdscreen0: lcdscreen@0 {
+               status = "okay";
+               compatible = "ti,tilcdc,panel";
+
+               backlight = <&tps_bl>;
+
+               panel-info {
+                       ac-bias         = <255>;
+                       ac-bias-intrpt  = <0>;
+                       dma-burst-sz    = <16>;
+                       bpp             = <32>;
+                       fdd             = <0x80>;
+                       sync-edge       = <0>;
+                       sync-ctrl       = <1>;
+                       raster-order    = <0>;
+                       fifo-th         = <0>;
+               };
+
+               display-timings {
+                       native-mode = <&timing0>;
+                       timing0: lcd {
+                               clock-frequency = <9142857>;
+                               hactive         = <480>;
+                               vactive         = <272>;
+                               hfront-porch    = <8>;
+                               hback-porch     = <43>;
+                               hsync-len       = <2>;
+                               vfront-porch    = <4>;
+                               vback-porch     = <2>;
+                               vsync-len       = <10>;
+                               hsync-active    = <1>;
+                               vsync-active    = <1>;
+                               pupdelay        = <10>;
+                               pondelay        = <10>;
+                       };
+               };
+       };
+};
+
+&uart0 {               /* console uart */
+       u-boot,dm-spl;
+       status = "okay";
+};
+
+&uart2 {
+       status = "okay";
+};
+
+&uart3 {
+       status = "okay";
+};
+
+&uart4 {
+       status = "okay";
+};
+
+&i2c0 {
+       u-boot,dm-spl;
+       status = "okay";
+       clock-frequency = <100000>;
+
+       tps: tps@24 {           /* PMIC controller */
+               u-boot,dm-spl;
+               reg = <0x24>;
+               compatible = "ti,tps65217";
+
+               tps_bl: backlight {
+                       compatible = "ti,tps65217-bl";
+                       isel = <1>;     /* 1 - ISET1, 2 ISET2 */
+                       fdim = <1000>;  /* TPS65217_BL_FDIM_1kHZ */
+                       default-brightness = <50>;
+               };
+       };
+       resetc: rstpsc@75 { /* reset controller */
+               compatible = "bur,rstpsc";
+               reg = <0x75>;
+
+               cooling-min-state = <0>;
+               cooling-max-state = <1>;        /* reset gets fired */
+               #cooling-cells = <2>;           /* min followed by max */
+       };
+       rtc0: rv3029c2@56 {
+               status = "okay";
+               #thermal-sensor-cells = <0>;
+               compatible = "rv3029c2";
+               reg = <0x56>;
+       };
+};
+
+&spi0 {
+       status = "okay";
+};
+
+&spi1 {
+       status = "okay";
+};
+
+&edma {
+       status = "okay";
+};
+
+&cppi41dma  {
+       status = "okay";
+};
+
+&usb {
+       status = "okay";
+};
+
+&usb_ctrl_mod {
+       status = "okay";
+};
+
+&usb0_phy {
+       status = "okay";
+};
+
+&usb1_phy {
+       status = "okay";
+};
+
+&usb0 {
+       status = "okay";
+       dr_mode = "host";
+};
+
+&usb1 {
+       status = "okay";
+       dr_mode = "host";
+};
+
+&davinci_mdio {
+       status = "okay";
+};
+
+&mac {
+       status = "okay";
+};
+
+&cpsw_emac0 {
+       phy_id = <&davinci_mdio>, <1>;
+       phy-mode = "mii";
+};
+
+&cpsw_emac1 {
+       phy_id = <&davinci_mdio>, <2>;
+       phy-mode = "mii";
+};
+
+&mmc1 {
+       u-boot,dm-pre-reloc;
+       vmmc-supply = <&vmmcsd_fixed>;
+       bus-width = <0x4>;
+       ti,non-removable;
+       ti,needs-special-hs-handling;
+       ti,vcc-aux-disable-is-sleep;
+       status = "okay";
+};
+
+&mmc2 {
+       u-boot,dm-pre-reloc;
+       vmmc-supply = <&vmmcsd_fixed>;
+       bus-width = <0x8>;
+       ti,non-removable;
+       ti,needs-special-hs-handling;
+       ti,vcc-aux-disable-is-sleep;
+       status = "okay";
+};
+
+&lcdc {
+       status = "okay";
+       ti,no-reset-on-init;
+       ti,no-idle-on-init;
+};
+
+&elm {
+       status = "okay";
+};
+
+&sham {
+       status = "okay";
+};
+
+&aes {
+       status = "okay";
+};
+
+&gpio0 {
+       u-boot,dm-spl;
+       ti,no-reset-on-init;
+};
+
+&gpio1 {
+       u-boot,dm-spl;
+       ti,no-reset-on-init;
+};
+
+&gpio2 {
+       u-boot,dm-spl;
+       ti,no-reset-on-init;
+};
+
+&gpio3 {
+       u-boot,dm-spl;
+       ti,no-reset-on-init;
+};
+
+&timer1 {              /* today unused */
+       status = "okay";
+       ti,no-reset-on-init;
+       ti,no-idle-on-init;
+};
+
+&timer2 {              /* used for vxworks primary timer device */
+       status = "okay";
+       ti,no-reset-on-init;
+       ti,no-idle-on-init;
+};
+
+&timer3 {              /* used sysdelay and hal tsc counter*/
+       status = "okay";
+       ti,no-reset-on-init;
+       ti,no-idle-on-init;
+};
+
+&timer4 {              /* used for PWM beeper */
+       status = "okay";
+       ti,no-reset-on-init;
+       ti,no-idle-on-init;
+};
+
+&timer5 {              /* used for PWM backlight */
+       status = "okay";
+       ti,no-reset-on-init;
+       ti,no-idle-on-init;
+};
+
+&timer6 {              /* used for cpsw end device */
+       status = "okay";
+       ti,no-reset-on-init;
+       ti,no-idle-on-init;
+};
+
+&timer7 {              /* used for cpsw end device */
+       status = "okay";
+       ti,no-reset-on-init;
+       ti,no-idle-on-init;
+};
+
+&wdt2 {
+       status = "okay";
+       ti,no-reset-on-init;
+       ti,no-idle-on-init;
+};
+
+&epwmss0 {
+       status = "okay";
+};
+
+&tscadc {
+       status = "okay";
+
+       tsc {
+               burtouch0: burtouch@0 {
+                       status = "okay";
+                       compatible = "bur,DdVxSfTouchXXX";
+                       bur,hwtree = "IF7";
+                       bur,KX0 = <0x0>;
+                       bur,KX1 = <0x0>;
+                       bur,KX2 = <0x0>;
+                       bur,KY0 = <0x0>;
+                       bur,KY1 = <0x0>;
+                       bur,KY2 = <0x0>;
+               };
+       };
+};
+
+&dcan0 {
+       status = "okay";
+};
+
+&dcan1 {
+       status = "okay";
+};
+
+&sham {
+       status = "disabled";
+};
+
+&aes {
+       status = "disabled";
+};
+
+&rng {
+       status = "disabled";
+};
index a10d9c1..eb0fe8b 100644 (file)
@@ -4,3 +4,4 @@ S:      Maintained
 F:     board/BuR/brxre1/
 F:     include/configs/brxre1.h
 F:     configs/brxre1_defconfig
+F:     arch/arm/dts/am335x-brxre1.dts
index 82c53d5..2d0ed41 100644 (file)
@@ -22,6 +22,7 @@
 #include <asm/io.h>
 #include <asm/emif.h>
 #include <asm/gpio.h>
+#include <dm.h>
 #include <i2c.h>
 #include <power/tps65217.h>
 #include "../common/bur_common.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
+static int rstctrl_rw(u8 reg, unsigned char rnw, void *pdat, int size)
+{
+       struct udevice *i2cdev;
+       int rc;
+
+       rc = i2c_get_chip_for_busnum(0, RSTCTRL_ADDR, 1, &i2cdev);
+       if (rc >= 0) {
+               if (rnw)
+                       rc = dm_i2c_read(i2cdev, reg, pdat, size);
+               else
+                       rc = dm_i2c_write(i2cdev, reg, pdat, size);
+       } else {
+               printf("%s: cannot get udevice for chip 0x%02x!\n",
+                      __func__, RSTCTRL_ADDR);
+       }
+
+       return rc;
+}
+
 #if defined(CONFIG_SPL_BUILD)
 /* TODO: check ram-timing ! */
 static const struct ddr_data ddr3_data = {
@@ -89,8 +109,8 @@ const struct dpll_params dpll_ddr3 = { 400, OSC-1, 1, -1, -1, -1, -1};
 
 void am33xx_spl_board_init(void)
 {
-       unsigned int oldspeed;
        unsigned short buf;
+       int rc;
 
        struct cm_perpll *const cmper = (struct cm_perpll *)CM_PER;
        struct cm_wkuppll *const cmwkup = (struct cm_wkuppll *)CM_WKUP;
@@ -114,23 +134,19 @@ void am33xx_spl_board_init(void)
        };
        do_enable_clocks(clk_domains, clk_modules_xre1specific, 1);
        /* power-OFF LCD-Display */
-       gpio_direction_output(LCD_PWR, 0);
+       if (gpio_request(LCD_PWR, "LCD_PWR") != 0)
+               printf("cannot request gpio for LCD_PWR!\n");
+       else if (gpio_direction_output(LCD_PWR, 0) != 0)
+               printf("cannot set direction output on LCD_PWR!\n");
 
        /* setup I2C */
        enable_i2c_pin_mux();
-       i2c_set_bus_num(0);
-       i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
 
-       /* power-ON  3V3 via Resetcontroller */
-       oldspeed = i2c_get_bus_speed();
-       if (i2c_set_bus_speed(CONFIG_SYS_OMAP24_I2C_SPEED_PSOC) >= 0) {
-               buf = RSTCTRL_FORCE_PWR_NEN | RSTCTRL_CAN_STB;
-               i2c_write(RSTCTRL_ADDR, RSTCTRL_CTRLREG, 1,
-                         (uint8_t *)&buf, sizeof(buf));
-               i2c_set_bus_speed(oldspeed);
-       } else {
-               puts("ERROR: i2c_set_bus_speed failed! (turn on PWR_nEN)\n");
-       }
+       /* power-ON 3V3 via Resetcontroller */
+       buf = RSTCTRL_FORCE_PWR_NEN | RSTCTRL_CAN_STB;
+       rc = rstctrl_rw(RSTCTRL_CTRLREG, 0, (uint8_t *)&buf, sizeof(buf));
+       if (rc != 0)
+               printf("ERROR: cannot write to resetc (turn on PWR_nEN)\n");
 
        pmicsetup(0, 0);
 }
@@ -153,7 +169,9 @@ void sdram_init(void)
  */
 int board_init(void)
 {
-       gpmc_init();
+       if (power_tps65217_init(0))
+               printf("WARN: cannot setup PMIC 0x24 @ bus #0, not found!.\n");
+
        return 0;
 }
 
@@ -164,19 +182,16 @@ int board_late_init(void)
        unsigned int cnt  = 3;
        unsigned short buf = 0xAAAA;
        unsigned char scratchreg = 0;
-       unsigned int oldspeed;
+       int rc;
 
        /* try to read out some boot-instruction from resetcontroller */
-       oldspeed = i2c_get_bus_speed();
-       if (i2c_set_bus_speed(CONFIG_SYS_OMAP24_I2C_SPEED_PSOC) >= 0) {
-               i2c_read(RSTCTRL_ADDR, RSTCTRL_SCRATCHREG, 1,
-                        &scratchreg, sizeof(scratchreg));
-               i2c_set_bus_speed(oldspeed);
-       } else {
-               puts("ERROR: i2c_set_bus_speed failed! (scratchregister)\n");
-       }
+       rc = rstctrl_rw(RSTCTRL_SCRATCHREG, 1, &scratchreg, sizeof(scratchreg));
+       if (rc != 0)
+               printf("ERROR: read scratchregister (resetc) failed!\n");
 
-       if (gpio_get_value(ESC_KEY)) {
+       if (gpio_request(ESC_KEY, "boot-key") != 0) {
+               printf("cannot request boot-key!\n");
+       } else if (gpio_get_value(ESC_KEY)) {
                do {
                        lcd_position_cursor(1, 8);
                        switch (cnt) {
@@ -266,14 +281,10 @@ int board_late_init(void)
                break;
        }
        /* write bootinfo into scratchregister of resetcontroller */
-       oldspeed = i2c_get_bus_speed();
-       if (i2c_set_bus_speed(CONFIG_SYS_OMAP24_I2C_SPEED_PSOC) >= 0) {
-               i2c_write(RSTCTRL_ADDR, RSTCTRL_SCRATCHREG, 1,
-                         (uint8_t *)&buf, sizeof(buf));
-               i2c_set_bus_speed(oldspeed);
-       } else {
-               puts("ERROR: i2c_set_bus_speed failed! (scratchregister)\n");
-       }
+       rc = rstctrl_rw(RSTCTRL_SCRATCHREG, 0, (uint8_t *)&buf, sizeof(buf));
+       if (rc != 0)
+               printf("ERROR: write scratchregister (resetc) failed!\n");
+
        /* setup othbootargs for bootvx-command (vxWorks bootline) */
        char othbootargs[128];
        snprintf(othbootargs, sizeof(othbootargs),
index a1f7c44..602c571 100644 (file)
@@ -181,6 +181,7 @@ void br_summaryscreen(void)
 void lcdpower(int on)
 {
        u32 pin, swval, i;
+       char buf[16] = { 0 };
 
        pin = env_get_ulong("ds1_pwr", 16, ~0UL);
 
@@ -191,6 +192,12 @@ void lcdpower(int on)
 
        for (i = 0; i < 3; i++) {
                if (pin != 0) {
+                       snprintf(buf, sizeof(buf), "ds1_pwr#%d", i);
+                       if (gpio_request(pin & 0x7F, buf) != 0) {
+                               printf("%s: not able to request gpio %s",
+                                      __func__, buf);
+                               continue;
+                       }
                        swval = pin & 0x80 ? 0 : 1;
                        if (on)
                                gpio_direction_output(pin & 0x7F, swval);
index c56a633..120f287 100644 (file)
@@ -3,64 +3,88 @@ CONFIG_ARCH_OMAP2PLUS=y
 CONFIG_SPL_GPIO_SUPPORT=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_AM33XX=y
+CONFIG_SYS_MPUCLK=1000
 CONFIG_TARGET_BRXRE1=y
 CONFIG_SPL_MMC_SUPPORT=y
 CONFIG_SPL_SERIAL_SUPPORT=y
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x4000
 CONFIG_SPL=y
-CONFIG_NR_DRAM_BANKS=1
-CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=1"
-CONFIG_BOOTDELAY=-2
-# CONFIG_CONSOLE_MUX is not set
-CONFIG_SYS_CONSOLE_IS_IN_ENV=y
+CONFIG_TPL_SYS_MALLOC_F_LEN=0x0
+# CONFIG_EXPERT is not set
+# CONFIG_FIT is not set
+CONFIG_OF_BOARD_SETUP=y
+CONFIG_BOOTDELAY=0
+CONFIG_USE_BOOTCOMMAND=y
+CONFIG_BOOTCOMMAND="mmc dev 1; run b_default"
 CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 CONFIG_VERSION_VARIABLE=y
 # CONFIG_DISPLAY_CPUINFO is not set
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_ARCH_MISC_INIT=y
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_SEPARATE_BSS=y
+# CONFIG_TPL_BANNER_PRINT is not set
 CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_NAND_SUPPORT is not set
 CONFIG_SPL_POWER_SUPPORT=y
 CONFIG_SPL_YMODEM_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 # CONFIG_CMD_BOOTD is not set
-# CONFIG_CMD_BOOTM is not set
 CONFIG_CMD_BOOTZ=y
-# CONFIG_CMD_GO is not set
 # CONFIG_CMD_IMI is not set
 # CONFIG_CMD_XIMG is not set
 # CONFIG_CMD_EDITENV is not set
 # CONFIG_CMD_CRC32 is not set
-CONFIG_CMD_UNZIP=y
+CONFIG_CMD_DM=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
-# CONFIG_CMD_LOADB is not set
 # CONFIG_CMD_LOADS is not set
 CONFIG_CMD_MMC=y
+CONFIG_CMD_PART=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_ITEST is not set
-# CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
 # CONFIG_CMD_NFS is not set
+CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
-CONFIG_CMD_BMP=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
+# CONFIG_SPL_DOS_PARTITION is not set
+CONFIG_OF_CONTROL=y
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_DEFAULT_DEVICE_TREE="am335x-brxre1"
+CONFIG_OF_SPL_REMOVE_PROPS=""
 CONFIG_ENV_IS_IN_MMC=y
+CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_NETCONSOLE=y
+CONFIG_DM=y
+CONFIG_SPL_DM=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
+# CONFIG_OF_TRANSLATE is not set
+CONFIG_DM_GPIO=y
+CONFIG_DM_I2C=y
+CONFIG_MISC=y
+CONFIG_DM_MMC=y
 CONFIG_MMC_OMAP_HS=y
+CONFIG_DM_ETH=y
 CONFIG_DRIVER_TI_CPSW=y
-CONFIG_SYS_NS16550=y
+CONFIG_DM_SERIAL=y
 CONFIG_USB=y
+CONFIG_DM_USB=y
 CONFIG_USB_MUSB_HOST=y
+CONFIG_USB_MUSB_GADGET=y
+CONFIG_USB_MUSB_TI=y
 CONFIG_USB_MUSB_DSPS=y
 CONFIG_USB_STORAGE=y
+CONFIG_USB_GADGET=y
 CONFIG_SYS_WHITE_ON_BLACK=y
 CONFIG_LCD=y
 # CONFIG_OMAP_WATCHDOG is not set
-CONFIG_FAT_WRITE=y
-CONFIG_OF_LIBFDT=y
+CONFIG_SPL_TINY_MEMSET=y
+# CONFIG_OF_LIBFDT_OVERLAY is not set
 # CONFIG_EFI_LOADER is not set
index f78a4e1..601b30d 100644 (file)
 #define V_OSCK                         26000000  /* Clock output from T2 */
 #define V_SCLK                         (V_OSCK)
 
-#define CONFIG_POWER_TPS65217
-
 #define CONFIG_MACH_TYPE               3589
-/* I2C IP block */
-#define CONFIG_SYS_OMAP24_I2C_SPEED_PSOC       20000
-
-/* MMC/SD IP block */
-#define CONFIG_SUPPORT_EMMC_BOOT
-
-/* Always 64 KiB env size */
-#define CONFIG_ENV_SIZE                        (64 << 10)
 
 #ifndef CONFIG_SPL_BUILD
 
@@ -80,13 +70,11 @@ BUR_COMMON_ENV \
 
 /* USB configuration */
 #define CONFIG_USB_MUSB_DISABLE_BULK_COMBINE_SPLIT
-#define CONFIG_AM335X_USB0
-#define CONFIG_AM335X_USB0_MODE        MUSB_HOST
-#define CONFIG_AM335X_USB1
-#define CONFIG_AM335X_USB1_MODE        MUSB_HOST
 
+/* Environment */
 #define CONFIG_SYS_MMC_ENV_DEV         1
 #define CONFIG_SYS_MMC_ENV_PART                2
+#define CONFIG_ENV_SIZE                        0x10000
 #define CONFIG_ENV_OFFSET              0x40000 /* TODO: Adresse definieren */
 #define CONFIG_ENV_OFFSET_REDUND       (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)
 #define CONFIG_SYS_REDUNDAND_ENVIRONMENT