From: Stefano Babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 1/8] wandboard: add Future Eletronics 7" WVGA LCD extension board
Date: Thu, 19 Dec 2013 11:36:28 +0100 [thread overview]
Message-ID: <52B2CC2C.5090502@denx.de> (raw)
In-Reply-To: <1387233845-4372-2-git-send-email-otavio@ossystems.com.br>
Hi Otavio,
one minor point.
On 16/12/2013 23:43, Otavio Salvador wrote:
> +int board_video_skip(void)
> +{
> + int i;
> + int ret;
> + int detected = 0;
> + char const *panel = getenv("panel");
> + if (!panel) {
> + for (i = 0; i < ARRAY_SIZE(displays); i++) {
> + struct display_info_t const *dev = displays+i;
> + if (dev->detect && dev->detect(dev)) {
> + panel = dev->mode.name;
> + detected = 1;
> + break;
> + }
> + }
> + if (!panel) {
> + panel = displays[0].mode.name;
> + printf("No panel detected: default to %s\n", panel);
> + i = 0;
> + }
> + } else {
> + for (i = 0; i < ARRAY_SIZE(displays); i++) {
> + if (!strcmp(panel, displays[i].mode.name))
> + break;
> + }
> + }
> + if (i < ARRAY_SIZE(displays)) {
> + ret = ipuv3_fb_init(&displays[i].mode, 0,
> + displays[i].pixfmt);
> +
> + if (!ret) {
> + displays[i].enable(displays+i);
> + printf("Display: %s (%ux%u) %s\n",
> + displays[i].mode.name,
> + displays[i].mode.xres,
> + displays[i].mode.yres,
> + (detected ? "[auto]" : ""));
> + } else
> + printf("LCD %s cannot be configured: %d\n",
> + displays[i].mode.name, ret);
> + } else {
> + printf("unsupported panel %s\n", panel);
> + return -EINVAL;
> + }
> +
> + return 0;
> }
>
This is identical to the nitrogen one, and quite identical to the same
function in sabresd. Or better, function in sabresd is older and has not
received the fixes as nitrogen (line with dev->detect).
IMHO the function is generic to be factorized. The display_info_t
structure lets us to specialize the behavior for each board, and the
generic part can be put in a common part.
> static void setup_display(void)
> {
> struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
> + struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
> int reg;
>
> enable_ipu_clock();
> imx_setup_hdmi();
>
> + /* Turn on LDB0, LDB1, IPU,IPU DI0 clocks */
> + reg = __raw_readl(&mxc_ccm->CCGR3);
> + reg |= MXC_CCM_CCGR3_LDB_DI0_MASK | MXC_CCM_CCGR3_LDB_DI1_MASK;
> + writel(reg, &mxc_ccm->CCGR3);
> +
> + /* set LDB0, LDB1 clk select to 011/011 */
> + reg = readl(&mxc_ccm->cs2cdr);
> + reg &= ~(MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_MASK
> + | MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_MASK);
> + reg |= (3 << MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_OFFSET)
> + | (3 << MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_OFFSET);
> + writel(reg, &mxc_ccm->cs2cdr);
> +
> + reg = readl(&mxc_ccm->cscmr2);
> + reg |= MXC_CCM_CSCMR2_LDB_DI0_IPU_DIV | MXC_CCM_CSCMR2_LDB_DI1_IPU_DIV;
> + writel(reg, &mxc_ccm->cscmr2);
> +
> reg = readl(&mxc_ccm->chsccdr);
> reg |= (CHSCCDR_CLK_SEL_LDB_DI0
> << MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET);
> + reg |= (CHSCCDR_CLK_SEL_LDB_DI0
> + << MXC_CCM_CHSCCDR_IPU1_DI1_CLK_SEL_OFFSET);
> writel(reg, &mxc_ccm->chsccdr);
> +
> + reg = IOMUXC_GPR2_BGREF_RRMODE_EXTERNAL_RES
> + | IOMUXC_GPR2_DI1_VS_POLARITY_ACTIVE_LOW
> + | IOMUXC_GPR2_DI0_VS_POLARITY_ACTIVE_LOW
> + | IOMUXC_GPR2_BIT_MAPPING_CH1_SPWG
> + | IOMUXC_GPR2_DATA_WIDTH_CH1_18BIT
> + | IOMUXC_GPR2_BIT_MAPPING_CH0_SPWG
> + | IOMUXC_GPR2_DATA_WIDTH_CH0_18BIT
> + | IOMUXC_GPR2_LVDS_CH0_MODE_DISABLED
> + | IOMUXC_GPR2_LVDS_CH1_MODE_ENABLED_DI0;
> + writel(reg, &iomux->gpr[2]);
> +
> + reg = readl(&iomux->gpr[3]);
> + reg = (reg & ~(IOMUXC_GPR3_LVDS1_MUX_CTL_MASK
> + | IOMUXC_GPR3_HDMI_MUX_CTL_MASK))
> + | (IOMUXC_GPR3_MUX_SRC_IPU1_DI0
> + << IOMUXC_GPR3_LVDS1_MUX_CTL_OFFSET);
> + writel(reg, &iomux->gpr[3]);
> +
> + /* Disable LCD backlight */
> + imx_iomux_v3_setup_pad(MX6_PAD_DI0_PIN4__GPIO4_IO20);
> + gpio_direction_input(IMX_GPIO_NR(4, 20));
> }
> #endif /* CONFIG_VIDEO_IPUV3 */
>
This function is also quite identical to all boards.You add here only
the disable of the LCD backlight. I can recognize some parts, that are
surely common to all implementations (enabling clocks). Even if the
setup of gpr[2]/[3] is identical, I can imagine that it could be board
specific. Anyway, any chance to factorize the code ?
>
> diff --git a/include/configs/wandboard.h b/include/configs/wandboard.h
> index e9c7e64..85f3c16 100644
> --- a/include/configs/wandboard.h
> +++ b/include/configs/wandboard.h
> @@ -55,6 +55,12 @@
> #define CONFIG_LOADADDR 0x12000000
> #define CONFIG_SYS_TEXT_BASE 0x17800000
>
> +/* I2C Configs */
> +#define CONFIG_CMD_I2C
> +#define CONFIG_SYS_I2C
> +#define CONFIG_SYS_I2C_MXC
> +#define CONFIG_SYS_I2C_SPEED 100000
> +
> /* MMC Configuration */
> #define CONFIG_FSL_ESDHC
> #define CONFIG_FSL_USDHC
> @@ -97,6 +103,7 @@
> #define CONFIG_VIDEO_LOGO
> #define CONFIG_VIDEO_BMP_LOGO
> #define CONFIG_IPUV3_CLK 260000000
> +#define CONFIG_CMD_HDMIDETECT
> #define CONFIG_IMX_HDMI
>
> #if defined(CONFIG_MX6DL) || defined(CONFIG_MX6S)
> @@ -134,7 +141,33 @@
> "fi; " \
> "fi\0" \
> "mmcargs=setenv bootargs console=${console},${baudrate} " \
> - "root=${mmcroot}\0" \
> + "root=${mmcroot}; run videoargs\0" \
> + "videoargs=" \
> + "setenv nextcon 0; " \
> + "if hdmidet; then " \
> + "setenv bootargs ${bootargs} " \
> + "video=mxcfb${nextcon}:dev=hdmi,1280x720M at 60," \
> + "if=RGB24; " \
> + "setenv fbmen fbmem=28M; " \
> + "setexpr nextcon ${nextcon} + 1; " \
> + "else " \
> + "echo - no HDMI monitor;" \
> + "fi; " \
> + "i2c dev 0; " \
> + "if i2c probe 0x10; then " \
> + "setenv bootargs ${bootargs} " \
> + "video=mxcfb${nextcon}:dev=lcd,800x480 at 60," \
> + "if=RGB666; " \
Why do we need this ? The kernel should get the setup for display from
DTS (display-timings node). Do you need to short-circuit DTS setup ?
> + "if test 0 -eq ${nextcon}; then " \
> + "setenv fbmem fbmem=10M; " \
> + "else " \
> + "setenv fbmem ${fbmem},10M; " \
> + "fi; " \
> + "setexpr nextcon ${nextcon} + 1; " \
> + "else " \
> + "echo '- no FWBADAPT-7WVGA-LCD-F07A-0102 display';" \
> + "fi; " \
> + "setenv bootargs ${bootargs} ${fbmem}\0" \
> "loadbootscript=" \
> "fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
> "bootscript=echo Running bootscript from mmc ...; " \
I was against adding so many scripts in CONFIG_ENV_EXTRA, but as Simon's
patches to move the default environment outside u-boot are not yet in
mainline, I will not stop patches for this.
Best regards,
Stefano Babic
--
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
next prev parent reply other threads:[~2013-12-19 10:36 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-16 22:43 [U-Boot] [PATCH v3 0/8] Pending patches for merging Otavio Salvador
2013-12-16 22:43 ` [U-Boot] [PATCH v3 1/8] wandboard: add Future Eletronics 7" WVGA LCD extension board Otavio Salvador
2013-12-19 10:36 ` Stefano Babic [this message]
2014-01-03 17:47 ` Otavio Salvador
2013-12-16 22:43 ` [U-Boot] [PATCH v3 2/8] mx6sabresd: Add eMMC specific environment to allow U-Boot update Otavio Salvador
2014-01-03 14:30 ` Stefano Babic
2014-01-03 14:48 ` Stefano Babic
2013-12-16 22:44 ` [U-Boot] [PATCH v3 3/8] imx: Easy enabling of SION per-pin using MUX_MODE_SION helper macro Otavio Salvador
2013-12-19 10:40 ` Stefano Babic
2014-01-03 14:30 ` Stefano Babic
2013-12-16 22:44 ` [U-Boot] [PATCH v3 4/8] mx28evk: Use 512k for fdt partition to align it Otavio Salvador
2013-12-19 10:41 ` Stefano Babic
2014-01-03 14:33 ` Stefano Babic
2013-12-16 22:44 ` [U-Boot] [PATCH v3 5/8] mx28evk: Add 'nandboot' environment command Otavio Salvador
2013-12-19 10:45 ` Stefano Babic
2013-12-19 11:02 ` Fabio Estevam
2014-01-03 14:33 ` Stefano Babic
2013-12-16 22:44 ` [U-Boot] [PATCH v3 6/8] mx28evk: Extend environment to easy write of NAND system Otavio Salvador
2014-01-03 14:34 ` Stefano Babic
2013-12-16 22:44 ` [U-Boot] [PATCH v3 7/8] ARM: mx6: Change the FDT loading address to avoid overlaping Otavio Salvador
2013-12-19 10:47 ` Stefano Babic
2014-01-03 14:34 ` Stefano Babic
2013-12-16 22:44 ` [U-Boot] [PATCH v3 8/8] ARM: mx6: Allow enablement of FEC Anatop based clock for all MX6 Otavio Salvador
2013-12-19 10:50 ` Stefano Babic
2014-01-03 14:35 ` Stefano Babic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52B2CC2C.5090502@denx.de \
--to=sbabic@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox