Skip to contentSkip to conversation

arm: add support for SoC S5P4418

RFC PATCH Superseded Stefan Bosch 3 participants 21 messages Mar 28, 2020 – Apr 10, 2020

Subsystems (6)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover arm: add support for SoC S5P4418

This patch adds support for SAMSUNG's/NEXELL's ARM Cortex-A9 based S5P4418 SoC, especially FriendlyARM's NanoPi2 and NanoPC-T2 boards. It is based on the following FriendlyARM's U-Boot version:
https://github.com/friendlyarm/u-boot/tree/nanopi2-v2016.01.

Main changes in relation to nanopi2-v2016.01:
- Cosmetic changes due to patman warnings/errors.
- MMC and Video drivers changed to DM.
- Configs reworked (e.g. "CONFIG_..." moved from s5p4418_nanopi2.h to s5p4418_nanopi2_defconfig)
- SPL related files are not included.
- MACH_TYPE_S5P4418 is not defined/used anymore.
- arch/arm/mach-nexell/include/mach/boot0.h added to generate the NSIH (Nexell System Information Header), substitudes tools/nexell.
- board/s5p4418/ renamed to board/friendlyarm/
- Only the NanoPi2 and NanoPC-T2 boards are supported yet because I do only have the NanoPC-T2 board to test the code (this board uses the NanoPi2 code).
- USB is not supported yet.

The patch-series has been checked by buildman (all arm boards and two m68k boards = M5235EVB):
buildman --step 0 -b master arm
buildman --step 0 -b master M5235EVB
There have been no new warnings or errors.

Changes in v2:
- arch/arm/mach-nexell/serial.c removed because this is for the UARTs of the S5P6818 SoC which is not supported yet. S5P4418 UARTs are different, here the (existing) PL011-code is used.
- line '... += spl/' in in arch/arm/mach-nexell/Makefile deleted, this change has already been stated in the commit message but was missing nethertheless.
- commit "i2c: mmc: add nexell driver (gpio, i2c, mmc, pwm)" splitted into separate commits for gpio, i2c, mmc, pwm.
- cosmetic: line "obj-$(CONFIG_NX_GPIO) += nx_gpio.o" in drivers/gpio/Makefile moved up.
- several Bugfixes in nx_i2c.c.
- the i2c-driver has been for s5p6818 only. Code extended approriately in order s5p4418 is also working.
- "probe_chip" added to the i2c-driver.
- doc/device-tree-bindings/i2c/nx_i2c.txt added.
- Since drivers/pwm/pwm-nexell.c is an adapted version of s5p-common/pwm.c an appropriately changed version of s5p-common/pwm.c is used now. Therefore arch/arm/mach-s5pc1xx/include/mach/pwm.h copied to arch/arm/mach-nexell/include/mach and s5p-common/Makefile changed appropriately.
- i2c: "nexell,s5pxx18-i2c"-driver is used now instead of "i2c-gpio". i2c0 and i2c1 added. I.e. dts files changed appropriately.
- dts: gmac-, ehci- and dwc2otg-entries removed because the appropriate functionality is not supported yet.
- s5p4418-pinctrl.dtsi removed because there is no pinctrl-driver available.
- "obj-$(CONFIG_ARCH_NEXELL) += s5p-common/" added to arch/arm/cpu/armv7/Makefile since s5p-common/pwm.c is used now instead of drivers/pwm/pwm-nexell.c.
- cosmetic: additional GPL license text removed, SPDX-License-Identifier is enough. Furthermore file path removed (two files).
- USB related configs removed because USB is not supported yet.
- CONFIG_CMD_MEMTEST moved from s5p4418_nanopi2.h to s5p4418_nanopi2_defconfig.
- MAINTAINERS: "F: drivers/pwm/pwm-nexell*" deleted because arch/arm/cpu/armv7/s5p-common/pwm.c is used now. Furthermore double line "F: drivers/video/nexell/" deleted.

Stefan Bosch (13):
arm: add mach-nexell (header files)
arm: add mach-nexell (all files except header files)
gpio: add nexell driver
i2c: add nexell driver
mmc: add nexell driver
pwm: add driver for nexell
video: add nexell video driver (soc: displaytop)
video: add nexell video driver (soc: mlc, mipi)
video: add nexell video driver (soc: lvds, hdmi)
video: add nexell video driver (soc: dpc, makefile)
video: add nexell video driver (display/video driver)
arm: add support for SoC s5p4418 (cpu) / nanopi2 board
arm: add (default) config for nanopi2 board

 MAINTAINERS                                        |   16 +
 arch/arm/Kconfig                                   |    7 +
 arch/arm/Makefile                                  |    1 +
 arch/arm/cpu/armv7/Makefile                        |    2 +
 arch/arm/cpu/armv7/s5p-common/Makefile             |    4 +
 arch/arm/cpu/armv7/s5p-common/pwm.c                |   56 +
 arch/arm/cpu/armv7/s5p4418/Makefile                |    6 +
 arch/arm/cpu/armv7/s5p4418/cpu.c                   |  120 ++
 arch/arm/dts/Makefile                              |    3 +
 arch/arm/dts/s5p4418-nanopi2.dts                   |  108 ++
 arch/arm/dts/s5p4418.dtsi                          |  148 ++
 arch/arm/mach-nexell/Kconfig                       |   67 +
 arch/arm/mach-nexell/Makefile                      |   13 +
 arch/arm/mach-nexell/clock.c                       |  869 +++++++++
 arch/arm/mach-nexell/cmd_boot_linux.c              |  145 ++
 arch/arm/mach-nexell/config.mk                     |   11 +
 arch/arm/mach-nexell/include/mach/boot0.h          |   40 +
 arch/arm/mach-nexell/include/mach/clk.h            |   24 +
 arch/arm/mach-nexell/include/mach/display.h        |  273 +++
 arch/arm/mach-nexell/include/mach/display_dev.h    |   37 +
 arch/arm/mach-nexell/include/mach/ehci.h           |  106 ++
 arch/arm/mach-nexell/include/mach/gpio.h           |   17 +
 arch/arm/mach-nexell/include/mach/mipi_display.h   |  215 +++
 arch/arm/mach-nexell/include/mach/nexell.h         |  352 ++++
 arch/arm/mach-nexell/include/mach/nx_gpio.h        |  103 ++
 arch/arm/mach-nexell/include/mach/pwm.h            |   54 +
 arch/arm/mach-nexell/include/mach/reset.h          |   19 +
 arch/arm/mach-nexell/include/mach/sec_reg.h        |   15 +
 arch/arm/mach-nexell/include/mach/tieoff.h         |  423 +++++
 arch/arm/mach-nexell/nx_gpio.c                     |  352 ++++
 arch/arm/mach-nexell/nx_sec_reg.c                  |   82 +
 arch/arm/mach-nexell/reg-call.S                    |   23 +
 arch/arm/mach-nexell/reset.c                       |   33 +
 arch/arm/mach-nexell/tieoff.c                      |  109 ++
 arch/arm/mach-nexell/timer.c                       |  297 ++++
 board/friendlyarm/Kconfig                          |   39 +
 board/friendlyarm/nanopi2/Kconfig                  |   12 +
 board/friendlyarm/nanopi2/MAINTAINERS              |    7 +
 board/friendlyarm/nanopi2/Makefile                 |    6 +
 board/friendlyarm/nanopi2/board.c                  |  567 ++++++
 board/friendlyarm/nanopi2/hwrev.c                  |  108 ++
 board/friendlyarm/nanopi2/hwrev.h                  |   15 +
 board/friendlyarm/nanopi2/lcds.c                   |  697 ++++++++
 board/friendlyarm/nanopi2/nxp-fb.h                 |   94 +
 board/friendlyarm/nanopi2/onewire.c                |  309 ++++
 board/friendlyarm/nanopi2/onewire.h                |   15 +
 configs/s5p4418_nanopi2_defconfig                  |  148 ++
 doc/README.s5p4418                                 |   63 +
 doc/device-tree-bindings/i2c/nx_i2c.txt            |   28 +
 drivers/gpio/Kconfig                               |    9 +
 drivers/gpio/Makefile                              |    1 +
 drivers/gpio/nx_gpio.c                             |  252 +++
 drivers/i2c/Kconfig                                |    9 +
 drivers/i2c/Makefile                               |    1 +
 drivers/i2c/nx_i2c.c                               |  649 +++++++
 drivers/mmc/Kconfig                                |    6 +
 drivers/mmc/Makefile                               |    1 +
 drivers/mmc/nexell_dw_mmc_dm.c                     |  350 ++++
 drivers/video/Kconfig                              |   10 +
 drivers/video/Makefile                             |    1 +
 drivers/video/nexell/Kconfig                       |   27 +
 drivers/video/nexell/Makefile                      |   12 +
 drivers/video/nexell/s5pxx18_dp.c                  |  338 ++++
 drivers/video/nexell/s5pxx18_dp_hdmi.c             |  543 ++++++
 drivers/video/nexell/s5pxx18_dp_lvds.c             |  274 +++
 drivers/video/nexell/s5pxx18_dp_mipi.c             |  677 +++++++
 drivers/video/nexell/s5pxx18_dp_rgb.c              |   69 +
 drivers/video/nexell/soc/Makefile                  |   11 +
 drivers/video/nexell/soc/s5pxx18_soc_disptop.c     |  185 ++
 drivers/video/nexell/soc/s5pxx18_soc_disptop.h     |  385 ++++
 drivers/video/nexell/soc/s5pxx18_soc_disptop_clk.c |  309 ++++
 drivers/video/nexell/soc/s5pxx18_soc_disptop_clk.h |   59 +
 drivers/video/nexell/soc/s5pxx18_soc_disptype.h    |   23 +
 drivers/video/nexell/soc/s5pxx18_soc_dpc.c         | 1569 +++++++++++++++++
 drivers/video/nexell/soc/s5pxx18_soc_dpc.h         |  444 +++++
 drivers/video/nexell/soc/s5pxx18_soc_hdmi.c        |   50 +
 drivers/video/nexell/soc/s5pxx18_soc_hdmi.h        |  488 +++++
 drivers/video/nexell/soc/s5pxx18_soc_lvds.c        |  278 +++
 drivers/video/nexell/soc/s5pxx18_soc_lvds.h        |   83 +
 drivers/video/nexell/soc/s5pxx18_soc_mipi.c        |  580 ++++++
 drivers/video/nexell/soc/s5pxx18_soc_mipi.h        |  291 +++
 drivers/video/nexell/soc/s5pxx18_soc_mlc.c         | 1861 ++++++++++++++++++++
 drivers/video/nexell/soc/s5pxx18_soc_mlc.h         |  429 +++++
 drivers/video/nexell_display.c                     |  665 +++++++
 include/configs/s5p4418_nanopi2.h                  |  265 +++
 85 files changed, 17462 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/s5p4418/Makefile
 create mode 100644 arch/arm/cpu/armv7/s5p4418/cpu.c
 create mode 100644 arch/arm/dts/s5p4418-nanopi2.dts
 create mode 100644 arch/arm/dts/s5p4418.dtsi
 create mode 100644 arch/arm/mach-nexell/Kconfig
 create mode 100644 arch/arm/mach-nexell/Makefile
 create mode 100644 arch/arm/mach-nexell/clock.c
 create mode 100644 arch/arm/mach-nexell/cmd_boot_linux.c
 create mode 100644 arch/arm/mach-nexell/config.mk
 create mode 100644 arch/arm/mach-nexell/include/mach/boot0.h
 create mode 100644 arch/arm/mach-nexell/include/mach/clk.h
 create mode 100644 arch/arm/mach-nexell/include/mach/display.h
 create mode 100644 arch/arm/mach-nexell/include/mach/display_dev.h
 create mode 100644 arch/arm/mach-nexell/include/mach/ehci.h
 create mode 100644 arch/arm/mach-nexell/include/mach/gpio.h
 create mode 100644 arch/arm/mach-nexell/include/mach/mipi_display.h
 create mode 100644 arch/arm/mach-nexell/include/mach/nexell.h
 create mode 100644 arch/arm/mach-nexell/include/mach/nx_gpio.h
 create mode 100644 arch/arm/mach-nexell/include/mach/pwm.h
 create mode 100644 arch/arm/mach-nexell/include/mach/reset.h
 create mode 100644 arch/arm/mach-nexell/include/mach/sec_reg.h
 create mode 100644 arch/arm/mach-nexell/include/mach/tieoff.h
 create mode 100644 arch/arm/mach-nexell/nx_gpio.c
 create mode 100644 arch/arm/mach-nexell/nx_sec_reg.c
 create mode 100644 arch/arm/mach-nexell/reg-call.S
 create mode 100644 arch/arm/mach-nexell/reset.c
 create mode 100644 arch/arm/mach-nexell/tieoff.c
 create mode 100644 arch/arm/mach-nexell/timer.c
 create mode 100644 board/friendlyarm/Kconfig
 create mode 100644 board/friendlyarm/nanopi2/Kconfig
 create mode 100644 board/friendlyarm/nanopi2/MAINTAINERS
 create mode 100644 board/friendlyarm/nanopi2/Makefile
 create mode 100644 board/friendlyarm/nanopi2/board.c
 create mode 100644 board/friendlyarm/nanopi2/hwrev.c
 create mode 100644 board/friendlyarm/nanopi2/hwrev.h
 create mode 100644 board/friendlyarm/nanopi2/lcds.c
 create mode 100644 board/friendlyarm/nanopi2/nxp-fb.h
 create mode 100644 board/friendlyarm/nanopi2/onewire.c
 create mode 100644 board/friendlyarm/nanopi2/onewire.h
 create mode 100644 configs/s5p4418_nanopi2_defconfig
 create mode 100644 doc/README.s5p4418
 create mode 100644 doc/device-tree-bindings/i2c/nx_i2c.txt
 create mode 100644 drivers/gpio/nx_gpio.c
 create mode 100644 drivers/i2c/nx_i2c.c
 create mode 100644 drivers/mmc/nexell_dw_mmc_dm.c
 create mode 100644 drivers/video/nexell/Kconfig
 create mode 100644 drivers/video/nexell/Makefile
 create mode 100644 drivers/video/nexell/s5pxx18_dp.c
 create mode 100644 drivers/video/nexell/s5pxx18_dp_hdmi.c
 create mode 100644 drivers/video/nexell/s5pxx18_dp_lvds.c
 create mode 100644 drivers/video/nexell/s5pxx18_dp_mipi.c
 create mode 100644 drivers/video/nexell/s5pxx18_dp_rgb.c
 create mode 100644 drivers/video/nexell/soc/Makefile
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_disptop.c
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_disptop.h
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_disptop_clk.c
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_disptop_clk.h
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_disptype.h
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_dpc.c
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_dpc.h
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_hdmi.c
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_hdmi.h
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_lvds.c
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_lvds.h
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_mipi.c
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_mipi.h
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_mlc.c
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_mlc.h
 create mode 100644 drivers/video/nexell_display.c
 create mode 100644 include/configs/s5p4418_nanopi2.h
Signature · 1 line
1.9.1
#1 lore raw

RFC PATCH v2 1/13 arm: add mach-nexell (header files)

Changes in relation to FriendlyARM's U-Boot nanopi2-v2016.01:
- DM_VIDEO support (display_dev.h).
- boot0.h added, handles NSIH --> tools/nexell obsolete.
- gpio.h: Include-path to errno.h changed.

---

Changes in v2:
- cosmetic: additional GPL license text removed, SPDX-License-Identifier is enough.

 arch/arm/mach-nexell/include/mach/boot0.h        |  40 +++
 arch/arm/mach-nexell/include/mach/clk.h          |  24 ++
 arch/arm/mach-nexell/include/mach/display.h      | 273 +++++++++++++++
 arch/arm/mach-nexell/include/mach/display_dev.h  |  37 ++
 arch/arm/mach-nexell/include/mach/ehci.h         | 106 ++++++
 arch/arm/mach-nexell/include/mach/gpio.h         |  17 +
 arch/arm/mach-nexell/include/mach/mipi_display.h | 215 ++++++++++++
 arch/arm/mach-nexell/include/mach/nexell.h       | 352 +++++++++++++++++++
 arch/arm/mach-nexell/include/mach/nx_gpio.h      | 103 ++++++
 arch/arm/mach-nexell/include/mach/reset.h        |  19 +
 arch/arm/mach-nexell/include/mach/sec_reg.h      |  15 +
 arch/arm/mach-nexell/include/mach/tieoff.h       | 423 +++++++++++++++++++++++
 12 files changed, 1624 insertions(+)
 create mode 100644 arch/arm/mach-nexell/include/mach/boot0.h
 create mode 100644 arch/arm/mach-nexell/include/mach/clk.h
 create mode 100644 arch/arm/mach-nexell/include/mach/display.h
 create mode 100644 arch/arm/mach-nexell/include/mach/display_dev.h
 create mode 100644 arch/arm/mach-nexell/include/mach/ehci.h
 create mode 100644 arch/arm/mach-nexell/include/mach/gpio.h
 create mode 100644 arch/arm/mach-nexell/include/mach/mipi_display.h
 create mode 100644 arch/arm/mach-nexell/include/mach/nexell.h
 create mode 100644 arch/arm/mach-nexell/include/mach/nx_gpio.h
 create mode 100644 arch/arm/mach-nexell/include/mach/reset.h
 create mode 100644 arch/arm/mach-nexell/include/mach/sec_reg.h
 create mode 100644 arch/arm/mach-nexell/include/mach/tieoff.h
arch/arm/mach-nexell/include/mach/boot0.h new file +40 -0
new file mode 100644
index 0000000..e05c07e
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0+
+ *
+ * NSIH (Nexell System Information Header) for FriendlyArm nanopi2 board
+ *
+ * The NSIH (first 512 Bytes of u-boot.bin) is necessary for the
+ * 2nd-Bootloader to get information like load address of U-Boot.
+ *
+ * 0x400 must be added to CONFIG_SYS_TEXT_BASE to have the actual load and
+ * start address because 2nd-Bootloader loads with an offset of 0x400
+ * (NSIH + 0x200 bytes are not loaded into RAM).
+ *
+ * It has been tested / is working with the following 2nd-Bootloader:
+ * "BL1 by Nexell V1.0.0-gd551e13 [Built on 2018-01-25 16:58:29]"
+ *
+ * (C) Copyright 2020 Stefan Bosch <[email protected]>
+ */
+
+#ifndef __BOOT0_H
+#define __BOOT0_H
+
+	ARM_VECTORS
+	.space	0x30
+	.word	(_end - _start) + 20 * 1024	/* 0x50: load size
+						 *       (bin + 20k for DTB) */
+	.space	0x4
+	.word	CONFIG_SYS_TEXT_BASE + 0x400	/* 0x58: load address */
+	.word	0x00000000
+	.word	CONFIG_SYS_TEXT_BASE + 0x400	/* 0x60: start address */
+	.space	0x198
+	.byte	'N'				/* 0x1FC: "NSIH" signature */
+	.byte	'S'
+	.byte	'I'
+	.byte	'H'
+
+	/* The NSIH + 0x200 bytes are omitted by the 2nd-Bootloader */
+	.space	0x200
+_start:
+	ARM_VECTORS
+
+#endif /* __BOOT0_H */
arch/arm/mach-nexell/include/mach/clk.h new file +24 -0
new file mode 100644
index 0000000..cc5589a
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0+
+ *
+ * (C) Copyright 2016 Nexell
+ * Hyunseok, Jung <[email protected]>
+ */
+
+#ifndef __ASM_ARM_ARCH_CLK_H_
+#define __ASM_ARM_ARCH_CLK_H_
+
+struct clk {
+	unsigned long rate;
+};
+
+void clk_init(void);
+
+struct clk *clk_get(const char *id);
+void clk_put(struct clk *clk);
+unsigned long clk_get_rate(struct clk *clk);
+long clk_round_rate(struct clk *clk, unsigned long rate);
+int clk_set_rate(struct clk *clk, unsigned long rate);
+int clk_enable(struct clk *clk);
+void clk_disable(struct clk *clk);
+
+#endif
arch/arm/mach-nexell/include/mach/display.h new file +273 -0

273 lines not on this page · raw message

arch/arm/mach-nexell/include/mach/display_dev.h new file +37 -0
new file mode 100644
index 0000000..77eb614
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0+
+ *
+ * Copyright (C) 2016  Nexell Co., Ltd.
+ *
+ * Author: junghyun, kim <[email protected]>
+ */
+
+#ifndef _NX__DISPLAY_DEV_H_
+#define _NX__DISPLAY_DEV_H_
+
+#if defined CONFIG_VIDEO || defined CONFIG_DM_VIDEO
+#include <video_fb.h>
+#elif defined CONFIG_LCD
+#include <lcd.h>
+#endif
+
+struct nx_display_dev {
+#if defined CONFIG_VIDEO || defined CONFIG_DM_VIDEO
+	GraphicDevice graphic_device;
+#elif defined CONFIG_LCD
+	vidinfo_t *panel_info;
+#endif
+	unsigned long base;
+	int module;
+	struct dp_sync_info sync;
+	struct dp_ctrl_info ctrl;
+	struct dp_plane_top top;
+	struct dp_plane_info planes[DP_PLANS_NUM];
+	int dev_type;
+	void *device;
+	struct dp_plane_info *fb_plane;
+	unsigned int depth;	/* byte per pixel */
+	unsigned int fb_addr;
+	unsigned int fb_size;
+};
+
+#endif
arch/arm/mach-nexell/include/mach/ehci.h new file +106 -0

106 lines not on this page · raw message

arch/arm/mach-nexell/include/mach/gpio.h new file +17 -0
new file mode 100644
index 0000000..7167d3c
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0+
+ *
+ * (C) Copyright 2016 Nexell
+ * DeokJin, Lee <[email protected]>
+ */
+
+#ifndef __ASM_ARCH_NEXELL_GPIO_H
+#define __ASM_ARCH_NEXELL_GPIO_H
+
+#include <asm/io.h>
+#include <linux/errno.h>
+
+#define PIN_BASE		0
+
+#define MAX_GPIO_BANKS		5
+
+#endif /* __ASM_ARCH_NEXELL_GPIO_H */
arch/arm/mach-nexell/include/mach/mipi_display.h new file +215 -0

215 lines not on this page · raw message

arch/arm/mach-nexell/include/mach/nexell.h new file +352 -0

352 lines not on this page · raw message

arch/arm/mach-nexell/include/mach/nx_gpio.h new file +103 -0

103 lines not on this page · raw message

arch/arm/mach-nexell/include/mach/reset.h new file +19 -0
new file mode 100644
index 0000000..e1301d4
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0+
+ *
+ * (C) Copyright 2016 Nexell
+ * Youngbok, Park <[email protected]>
+ */
+
+#ifndef __NEXELL_RESET__
+#define __NEXELL_RESET__
+
+#define NUMBER_OF_RESET_MODULE_PIN      69
+
+enum rstcon {
+	RSTCON_ASSERT	= 0UL,
+	RSTCON_NEGATE	= 1UL
+};
+
+void nx_rstcon_setrst(u32 rstindex, enum rstcon status);
+
+#endif /* __NEXELL_RESET__ */
arch/arm/mach-nexell/include/mach/sec_reg.h new file +15 -0
new file mode 100644
index 0000000..e3ae5ac
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0+
+ *
+ * (C) Copyright 2016 Nexell
+ * Youngbok, Park <[email protected]>
+ */
+
+#define NEXELL_L2C_SEC_ID	0
+#define NEXELL_MALI_SEC_ID	2
+#define NEXELL_MIPI_SEC_ID	4
+#define NEXELL_TOFF_SEC_ID	6
+
+int write_sec_reg_by_id(void __iomem *reg, int val, int id);
+int read_sec_reg_by_id(void __iomem *reg, int id);
+int read_sec_reg(void __iomem *reg);
+int write_sec_reg(void __iomem *reg, int val);
arch/arm/mach-nexell/include/mach/tieoff.h new file +423 -0

423 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

RFC PATCH v2 2/13 arm: add mach-nexell (all files except header files)

In reply to Stefan Bosch

Changes in relation to FriendlyARM's U-Boot nanopi2-v2016.01:
- SPL not supported yet --> no spl-directory in arch/arm/mach-nexell. Appropriate line in Makefile removed.
- clock.c: 'section(".data")' added to declaration of clk_periphs[] and core_hz.
- Kconfig: Changes to have a structure like in mach-bcm283x/Kconfig, e.g. "config ..." entries moved from other Kconfig.
- timer.c: 'section(".data")' added to declaration of timestamp and lastdec.
- arch/arm/mach-nexell/serial.c removed because this is for the UARTs of the S5P6818 SoC which is not supported yet. S5P4418 UARTs are different, here the (existing) PL011-code is used.

---

Changes in v2:
- arch/arm/mach-nexell/serial.c removed because this is for the UARTs of the S5P6818 SoC which is not supported yet. S5P4418 UARTs are different, here the (existing) PL011-code is used.
- line '... += spl/' in in arch/arm/mach-nexell/Makefile deleted, this change has already been stated in the commit message but was missing nethertheless.

 arch/arm/Kconfig                      |   7 +
 arch/arm/Makefile                     |   1 +
 arch/arm/mach-nexell/Kconfig          |  67 +++
 arch/arm/mach-nexell/Makefile         |  13 +
 arch/arm/mach-nexell/clock.c          | 869 ++++++++++++++++++++++++++++++++++
 arch/arm/mach-nexell/cmd_boot_linux.c | 145 ++++++
 arch/arm/mach-nexell/config.mk        |  11 +
 arch/arm/mach-nexell/nx_gpio.c        | 352 ++++++++++++++
 arch/arm/mach-nexell/nx_sec_reg.c     |  82 ++++
 arch/arm/mach-nexell/reg-call.S       |  23 +
 arch/arm/mach-nexell/reset.c          |  33 ++
 arch/arm/mach-nexell/tieoff.c         | 109 +++++
 arch/arm/mach-nexell/timer.c          | 297 ++++++++++++
 13 files changed, 2009 insertions(+)
 create mode 100644 arch/arm/mach-nexell/Kconfig
 create mode 100644 arch/arm/mach-nexell/Makefile
 create mode 100644 arch/arm/mach-nexell/clock.c
 create mode 100644 arch/arm/mach-nexell/cmd_boot_linux.c
 create mode 100644 arch/arm/mach-nexell/config.mk
 create mode 100644 arch/arm/mach-nexell/nx_gpio.c
 create mode 100644 arch/arm/mach-nexell/nx_sec_reg.c
 create mode 100644 arch/arm/mach-nexell/reg-call.S
 create mode 100644 arch/arm/mach-nexell/reset.c
 create mode 100644 arch/arm/mach-nexell/tieoff.c
 create mode 100644 arch/arm/mach-nexell/timer.c
arch/arm/Kconfig +7 -0
index a623ef5..469aa65 100644
@@ -875,6 +875,11 @@ config ARCH_MX5
 	select CPU_V7A
 	imply MXC_GPIO
 
+config ARCH_NEXELL
+	bool "Nexell S5P4418/S5P6818 SoC"
+	select ENABLE_ARM_SOC_BOOT0_HOOK
+	select DM
+
 config ARCH_OWL
 	bool "Actions Semi OWL SoCs"
 	select ARM64
@@ -1797,6 +1802,8 @@ source "arch/arm/cpu/armv8/Kconfig"
 
 source "arch/arm/mach-imx/Kconfig"
 
+source "arch/arm/mach-nexell/Kconfig"
+
 source "board/bosch/shc/Kconfig"
 source "board/bosch/guardian/Kconfig"
 source "board/CarMediaLab/flea3/Kconfig"
arch/arm/Makefile +1 -0
index 1e60a9f..5a390b8 100644
@@ -67,6 +67,7 @@ machine-$(CONFIG_ARCH_MESON)		+= meson
 machine-$(CONFIG_ARCH_MVEBU)		+= mvebu
 # TODO: rename CONFIG_TEGRA -> CONFIG_ARCH_TEGRA
 # TODO: rename CONFIG_ORION5X -> CONFIG_ARCH_ORION5X
+machine-$(CONFIG_ARCH_NEXELL)		+= nexell
 machine-$(CONFIG_ORION5X)		+= orion5x
 machine-$(CONFIG_ARCH_OMAP2PLUS)	+= omap2
 machine-$(CONFIG_ARCH_OWL)		+= owl
arch/arm/mach-nexell/Kconfig new file +67 -0

67 lines not on this page · raw message

arch/arm/mach-nexell/Makefile new file +13 -0
new file mode 100644
index 0000000..10b3963
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2016 Nexell
+# Hyunseok, Jung <[email protected]>
+
+obj-y				+= clock.o
+obj-y				+= timer.o
+obj-y				+= reset.o
+obj-y				+= nx_gpio.o
+obj-y				+= tieoff.o
+obj-$(CONFIG_ARCH_S5P4418)	+= reg-call.o
+obj-$(CONFIG_ARCH_S5P4418)	+= nx_sec_reg.o
+obj-$(CONFIG_CMD_BOOTL)		+= cmd_boot_linux.o
arch/arm/mach-nexell/clock.c new file +869 -0

869 lines not on this page · raw message

arch/arm/mach-nexell/cmd_boot_linux.c new file +145 -0

145 lines not on this page · raw message

arch/arm/mach-nexell/config.mk new file +11 -0
new file mode 100644
index 0000000..7b06626
@@ -0,0 +1,11 @@
+#
+# (C) Copyright 2016 Nexell
+# junghyun kim<[email protected]>
+#
+# SPDX-License-Identifier:      GPL-2.0+
+#
+
+SOCDIR=CPUDIR/$(VENDOR)
+MACHDIR=$(patsubst %,arch/arm/mach-%,$(machine-y))
+
+LDPPFLAGS += -DMACHDIR=$(MACHDIR) -DSOCDIR=$(SOCDIR)
arch/arm/mach-nexell/nx_gpio.c new file +352 -0

352 lines not on this page · raw message

arch/arm/mach-nexell/nx_sec_reg.c new file +82 -0

82 lines not on this page · raw message

arch/arm/mach-nexell/reg-call.S new file +23 -0
new file mode 100644
index 0000000..5fdf515
@@ -0,0 +1,23 @@
+#include <asm-offsets.h>
+#include <config.h>
+#include <linux/linkage.h>
+
+#define ___asm_opcode_identity32(x) ((x) & 0xFFFFFFFF)
+#define __opcode_to_mem_arm(x) ___opcode_identity32(x)
+#define ___asm_opcode_to_mem_arm(x) ___asm_opcode_identity32(x)
+
+#define ___opcode_identity32(x) ((u32)(x))
+#define ___inst_arm(x) .long x
+#define __inst_arm(x) ___inst_arm(___asm_opcode_to_mem_arm(x))
+
+#define __inst_arm_thumb32(arm_opcode, thumb_opcode) __inst_arm(arm_opcode)
+
+#define __SMC(imm4) __inst_arm_thumb32(                                 \
+        0xE1600070 | (((imm4) & 0xF) << 0),                             \
+        0xF7F08000 | (((imm4) & 0xF) << 16)                             \
+)
+
+ENTRY(__invoke_nexell_fn_smc)
+	__SMC(0)
+	bx      lr
+ENDPROC(__invoke_nexell_fn_smc)
arch/arm/mach-nexell/reset.c new file +33 -0
new file mode 100644
index 0000000..1f732a3
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2016 Nexell
+ * Youngbok, Park <[email protected]>
+ */
+
+/*
+ *FIXME : Not support device tree & reset control driver.
+ *        will remove after support device tree & reset control driver.
+ */
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/nexell.h>
+#include <asm/arch/reset.h>
+
+struct	nx_rstcon_registerset {
+	u32	regrst[(NUMBER_OF_RESET_MODULE_PIN + 31) >> 5];
+};
+
+static struct nx_rstcon_registerset *nx_rstcon =
+			(struct nx_rstcon_registerset *)PHY_BASEADDR_RSTCON;
+
+void nx_rstcon_setrst(u32 rstindex, enum rstcon status)
+{
+	u32 regnum, bitpos, curstat;
+
+	regnum		= rstindex >> 5;
+	curstat		= (u32)readl(&nx_rstcon->regrst[regnum]);
+	bitpos		= rstindex & 0x1f;
+	curstat		&= ~(1UL << bitpos);
+	curstat		|= (status & 0x01) << bitpos;
+	writel(curstat, &nx_rstcon->regrst[regnum]);
+}
arch/arm/mach-nexell/tieoff.c new file +109 -0

109 lines not on this page · raw message

arch/arm/mach-nexell/timer.c new file +297 -0

297 lines not on this page · raw message

Signature · 1 line
1.9.1
#3 lore raw

RFC PATCH v2 3/13 gpio: add nexell driver

In reply to Stefan Bosch

---

Changes in v2:
- commit "i2c: mmc: add nexell driver (gpio, i2c, mmc, pwm)" splitted into separate commits for gpio, i2c, mmc, pwm.
- cosmetic: line "obj-$(CONFIG_NX_GPIO) += nx_gpio.o" in drivers/gpio/Makefile moved up.

 drivers/gpio/Kconfig   |   9 ++
 drivers/gpio/Makefile  |   1 +
 drivers/gpio/nx_gpio.c | 252 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 262 insertions(+)
 create mode 100644 drivers/gpio/nx_gpio.c
drivers/gpio/Kconfig +9 -0
index 1de6f52..febda89 100644
@@ -421,4 +421,13 @@ config MT7621_GPIO
 	help
 	  Say yes here to support MediaTek MT7621 compatible GPIOs.
 
+config NX_GPIO
+	bool "Nexell GPIO driver"
+	depends on DM_GPIO
+	help
+	  Support GPIO access on Nexell SoCs. The GPIOs are arranged into
+	  a number of banks (different for each SoC type) each with 32 GPIOs.
+	  The GPIOs for a device are defined in the device tree with one node
+	  for each bank.
+
 endmenu
drivers/gpio/Makefile +1 -0
index 449046b..cb20478 100644
@@ -64,4 +64,5 @@ obj-$(CONFIG_$(SPL_)PCF8575_GPIO)	+= pcf8575_gpio.o
 obj-$(CONFIG_PM8916_GPIO)	+= pm8916_gpio.o
 obj-$(CONFIG_MT7621_GPIO)	+= mt7621_gpio.o
 obj-$(CONFIG_MSCC_SGPIO)	+= mscc_sgpio.o
+obj-$(CONFIG_NX_GPIO)		+= nx_gpio.o
 obj-$(CONFIG_SIFIVE_GPIO)	+= sifive-gpio.o
drivers/gpio/nx_gpio.c new file +252 -0

252 lines not on this page · raw message

Signature · 1 line
1.9.1
#4 lore raw

RFC PATCH v2 4/13 i2c: add nexell driver

In reply to Stefan Bosch

Changes in relation to FriendlyARM's U-Boot nanopi2-v2016.01:
- i2c/nx_i2c.c: Some adaptions mainly because of changes in "struct udevice".
- several Bugfixes in nx_i2c.c.
- the driver has been for s5p6818 only. Code extended appropriately in order s5p4418 is also working.
- "probe_chip" added.

---

Changes in v2:
- commit "i2c: mmc: add nexell driver (gpio, i2c, mmc, pwm)" splitted into separate commits for gpio, i2c, mmc, pwm.
- several Bugfixes in nx_i2c.c.
- the i2c-driver has been for s5p6818 only. Code extended approriately in order s5p4418 is also working.
- "probe_chip" added to the i2c-driver.
- doc/device-tree-bindings/i2c/nx_i2c.txt added.

 doc/device-tree-bindings/i2c/nx_i2c.txt |  28 ++
 drivers/i2c/Kconfig                     |   9 +
 drivers/i2c/Makefile                    |   1 +
 drivers/i2c/nx_i2c.c                    | 649 ++++++++++++++++++++++++++++++++
 4 files changed, 687 insertions(+)
 create mode 100644 doc/device-tree-bindings/i2c/nx_i2c.txt
 create mode 100644 drivers/i2c/nx_i2c.c
doc/device-tree-bindings/i2c/nx_i2c.txt new file +28 -0
new file mode 100644
index 0000000..9f3abe7
@@ -0,0 +1,28 @@
+I2C controller embedded in Nexell's/Samsung's SoC S5P4418 and S5P6818
+
+Driver:
+- drivers/i2c/nx_i2c.c
+
+Required properties:
+- #address-cells = <1>;
+- #size-cells = <0>;
+- compatible = "nexell,s5pxx18-i2c";
+- reg = <i2c_base 0x100>;
+        Where i2c_base has to be the base address of the i2c-register set.
+        I2C0: 0xc00a4000
+        I2C1: 0xc00a5000
+        I2C2: 0xc00a6000
+
+Optional properties:
+- clock-frequency: Desired I2C bus frequency in Hz, default value is 100000.
+- i2c-sda-delay-ns (S5P6818 only): SDA delay in ns, default value is 0.
+- Child nodes conforming to i2c bus binding.
+
+Example:
+	i2c0:i2c at c00a4000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "nexell,s5pxx18-i2c";
+		reg = <0xc00a4000 0x100>;
+		clock-frequency = <400000>;
+	};
drivers/i2c/Kconfig +9 -0
index 03d2fed..2cd0ed3 100644
@@ -317,6 +317,15 @@ config SYS_MXC_I2C8_SLAVE
 	 MXC I2C8 Slave
 endif
 
+config SYS_I2C_NEXELL
+	bool "Nexell I2C driver"
+	depends on DM_I2C
+	help
+	  Add support for the Nexell I2C driver. This is used with various
+	  Nexell parts such as S5Pxx18 series SoCs. All chips
+	  have several I2C ports and all are provided, controlled by the
+	  device tree.
+
 config SYS_I2C_OMAP24XX
 	bool "TI OMAP2+ I2C driver"
 	depends on ARCH_OMAP2PLUS || ARCH_K3
drivers/i2c/Makefile +1 -0
index f5a471f..64b8ead 100644
@@ -26,6 +26,7 @@ obj-$(CONFIG_SYS_I2C_LPC32XX) += lpc32xx_i2c.o
 obj-$(CONFIG_SYS_I2C_MESON) += meson_i2c.o
 obj-$(CONFIG_SYS_I2C_MVTWSI) += mvtwsi.o
 obj-$(CONFIG_SYS_I2C_MXC) += mxc_i2c.o
+obj-$(CONFIG_SYS_I2C_NEXELL) += nx_i2c.o
 obj-$(CONFIG_SYS_I2C_OMAP24XX) += omap24xx_i2c.o
 obj-$(CONFIG_SYS_I2C_RCAR_I2C) += rcar_i2c.o
 obj-$(CONFIG_SYS_I2C_RCAR_IIC) += rcar_iic.o
drivers/i2c/nx_i2c.c new file +649 -0

649 lines not on this page · raw message

Signature · 1 line
1.9.1
#5 lore raw

RFC PATCH v2 4/13 i2c: add nexell driver

Hello Stefan,

Am 28.03.2020 um 10:43 schrieb Stefan Bosch:

Quoted 20 lines

Changes in relation to FriendlyARM's U-Boot nanopi2-v2016.01:
- i2c/nx_i2c.c: Some adaptions mainly because of changes in "struct udevice".
- several Bugfixes in nx_i2c.c.
- the driver has been for s5p6818 only. Code extended appropriately in order s5p4418 is also working.
- "probe_chip" added.

---

Changes in v2:
- commit "i2c: mmc: add nexell driver (gpio, i2c, mmc, pwm)" splitted into separate commits for gpio, i2c, mmc, pwm.
- several Bugfixes in nx_i2c.c.
- the i2c-driver has been for s5p6818 only. Code extended approriately in order s5p4418 is also working.
- "probe_chip" added to the i2c-driver.
- doc/device-tree-bindings/i2c/nx_i2c.txt added.

Quoted 7 lines
  doc/device-tree-bindings/i2c/nx_i2c.txt |  28 ++
  drivers/i2c/Kconfig                     |   9 +
  drivers/i2c/Makefile                    |   1 +
  drivers/i2c/nx_i2c.c                    | 649 ++++++++++++++++++++++++++++++++
  4 files changed, 687 insertions(+)

create mode 100644 doc/device-tree-bindings/i2c/nx_i2c.txt create mode 100644 drivers/i2c/nx_i2c.c

I do not find this patch in patchwork ...

Thanks for splitting the big patch into several patches.

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de
author
#6 lore raw

RFC PATCH v2 4/13 i2c: add nexell driver

Hi Heiko,

I assume that patchwork does get the patch-series automatically when I send it to u-boot at lists.denx.de, or am I wrong? Perhaps it is in some pipeline?

At least the patch-series appeared in U-Boot Digest ("[RFC PATCH v2 04/13] i2c: add nexell driver" is in Vol 142, Issue 58).

Regards
Stefan

Am 08.04.20 um 06:08 schrieb Heiko Schocher:

Quoted 40 lines

Hello Stefan,

Am 28.03.2020 um 10:43 schrieb Stefan Bosch:

Quoted 20 lines

Changes in relation to FriendlyARM's U-Boot nanopi2-v2016.01:
- i2c/nx_i2c.c: Some adaptions mainly because of changes in ?? "struct udevice".
- several Bugfixes in nx_i2c.c.
- the driver has been for s5p6818 only. Code extended appropriately ?? in order s5p4418 is also working.
- "probe_chip" added.

---

Changes in v2:
- commit "i2c: mmc: add nexell driver (gpio, i2c, mmc, pwm)" splitted ?? into separate commits for gpio, i2c, mmc, pwm.
- several Bugfixes in nx_i2c.c.
- the i2c-driver has been for s5p6818 only. Code extended approriately ?? in order s5p4418 is also working.
- "probe_chip" added to the i2c-driver.
- doc/device-tree-bindings/i2c/nx_i2c.txt added.

Quoted 8 lines
? doc/device-tree-bindings/i2c/nx_i2c.txt |? 28 ++
? drivers/i2c/Kconfig???????????????????? |?? 9 +
? drivers/i2c/Makefile??????????????????? |?? 1 +
? drivers/i2c/nx_i2c.c??????????????????? | 649 

++++++++++++++++++++++++++++++++
? 4 files changed, 687 insertions(+)
? create mode 100644 doc/device-tree-bindings/i2c/nx_i2c.txt ? create mode 100644 drivers/i2c/nx_i2c.c

I do not find this patch in patchwork ...

Thanks for splitting the big patch into several patches.

bye,
Heiko

#7 lore raw

RFC PATCH v2 4/13 i2c: add nexell driver

Hello Stefan,

Am 08.04.2020 um 19:57 schrieb Stefan B.:

Quoted 4 lines

Hi Heiko,

I assume that patchwork does get the patch-series automatically when I send it to u-boot at lists.denx.de, or am I wrong? Perhaps it is in some pipeline?

normally, yes, patchwork gets the patch automatically...

Quoted 2 lines

At least the patch-series appeared in U-Boot Digest ("[RFC PATCH v2 04/13] i2c: add nexell driver" is in Vol 142, Issue 58).

bye,
Heiko

Quoted 46 lines

Regards
Stefan

Am 08.04.20 um 06:08 schrieb Heiko Schocher:

Quoted 39 lines

Hello Stefan,

Am 28.03.2020 um 10:43 schrieb Stefan Bosch:

Quoted 20 lines

Changes in relation to FriendlyARM's U-Boot nanopi2-v2016.01:
- i2c/nx_i2c.c: Some adaptions mainly because of changes in ?? "struct udevice".
- several Bugfixes in nx_i2c.c.
- the driver has been for s5p6818 only. Code extended appropriately ?? in order s5p4418 is also working.
- "probe_chip" added.

---

Changes in v2:
- commit "i2c: mmc: add nexell driver (gpio, i2c, mmc, pwm)" splitted ?? into separate commits for gpio, i2c, mmc, pwm.
- several Bugfixes in nx_i2c.c.
- the i2c-driver has been for s5p6818 only. Code extended approriately ?? in order s5p4418 is also working.
- "probe_chip" added to the i2c-driver.
- doc/device-tree-bindings/i2c/nx_i2c.txt added.

Quoted 7 lines
? doc/device-tree-bindings/i2c/nx_i2c.txt |? 28 ++
? drivers/i2c/Kconfig???????????????????? |?? 9 +
? drivers/i2c/Makefile??????????????????? |?? 1 +
? drivers/i2c/nx_i2c.c??????????????????? | 649 ++++++++++++++++++++++++++++++++

? 4 files changed, 687 insertions(+)
? create mode 100644 doc/device-tree-bindings/i2c/nx_i2c.txt ? create mode 100644 drivers/i2c/nx_i2c.c

I do not find this patch in patchwork ...

Thanks for splitting the big patch into several patches.

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de
#8 lore raw

RFC PATCH v2 5/13 mmc: add nexell driver

In reply to Stefan Bosch

Changes in relation to FriendlyARM's U-Boot nanopi2-v2016.01:
- mmc: nexell_dw_mmc.c changed to nexell_dw_mmc_dm.c (switched to DM).

---

Changes in v2:
- commit "i2c: mmc: add nexell driver (gpio, i2c, mmc, pwm)" splitted into separate commits for gpio, i2c, mmc, pwm.

 drivers/mmc/Kconfig            |   6 +
 drivers/mmc/Makefile           |   1 +
 drivers/mmc/nexell_dw_mmc_dm.c | 350 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 357 insertions(+)
 create mode 100644 drivers/mmc/nexell_dw_mmc_dm.c
drivers/mmc/Kconfig +6 -0
index 2f0eedc..bb8e7c0 100644
@@ -253,6 +253,12 @@ config MMC_DW_SNPS
 	  This selects support for Synopsys DesignWare Memory Card Interface driver
 	  extensions used in various Synopsys ARC devboards.
 
+config NEXELL_DWMMC
+	bool "Nexell SD/MMC controller support"
+	depends on ARCH_NEXELL
+	depends on MMC_DW
+	default y
+
 config MMC_MESON_GX
 	bool "Meson GX EMMC controller support"
 	depends on DM_MMC && BLK && ARCH_MESON
drivers/mmc/Makefile +1 -0
index 9c1f8e5..a7b5a7b 100644
@@ -43,6 +43,7 @@ obj-$(CONFIG_SH_MMCIF) += sh_mmcif.o
 obj-$(CONFIG_SH_SDHI) += sh_sdhi.o
 obj-$(CONFIG_STM32_SDMMC2) += stm32_sdmmc2.o
 obj-$(CONFIG_JZ47XX_MMC) += jz_mmc.o
+obj-$(CONFIG_NEXELL_DWMMC) += nexell_dw_mmc_dm.o
 
 # SDHCI
 obj-$(CONFIG_MMC_SDHCI)			+= sdhci.o
drivers/mmc/nexell_dw_mmc_dm.c new file +350 -0

350 lines not on this page · raw message

Signature · 1 line
1.9.1
#9 lore raw

RFC PATCH v2 5/13 mmc: add nexell driver

Hi,

Quoted 2 lines · Stefan Bosch

Changes in relation to FriendlyARM's U-Boot nanopi2-v2016.01:
- mmc: nexell_dw_mmc.c changed to nexell_dw_mmc_dm.c (switched to DM).

It doesn't need to add postfix as _dm.

Quoted 19 lines

---

Changes in v2:
- commit "i2c: mmc: add nexell driver (gpio, i2c, mmc, pwm)" splitted into separate commits for gpio, i2c, mmc, pwm.

 drivers/mmc/Kconfig            |   6 +
 drivers/mmc/Makefile           |   1 +
 drivers/mmc/nexell_dw_mmc_dm.c | 350 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 357 insertions(+)
 create mode 100644 drivers/mmc/nexell_dw_mmc_dm.c
drivers/mmc/Kconfig +0 -0
index 2f0eedc..bb8e7c0 100644

drivers/mmc/Kconfig config MMC_DW_SNPS · line 260

Quoted 8 lines
drivers/mmc/Kconfig +5 -0
@@ -253,6 +253,12 @@ config MMC_DW_SNPS
 	  This selects support for Synopsys DesignWare Memory Card Interface driver
 	  extensions used in various Synopsys ARC devboards.
 
+config NEXELL_DWMMC
+	bool "Nexell SD/MMC controller support"
+	depends on ARCH_NEXELL
+	depends on MMC_DW
+	default y

Not depends on DM_MMC?

Quoted 79 lines
drivers/mmc/Kconfig +1 -0
+
 config MMC_MESON_GX
 	bool "Meson GX EMMC controller support"
 	depends on DM_MMC && BLK && ARCH_MESON
drivers/mmc/Makefile +1 -0
index 9c1f8e5..a7b5a7b 100644
@@ -43,6 +43,7 @@ obj-$(CONFIG_SH_MMCIF) += sh_mmcif.o
 obj-$(CONFIG_SH_SDHI) += sh_sdhi.o
 obj-$(CONFIG_STM32_SDMMC2) += stm32_sdmmc2.o
 obj-$(CONFIG_JZ47XX_MMC) += jz_mmc.o
+obj-$(CONFIG_NEXELL_DWMMC) += nexell_dw_mmc_dm.o
 
 # SDHCI
 obj-$(CONFIG_MMC_SDHCI)			+= sdhci.o
drivers/mmc/nexell_dw_mmc_dm.c new file +57 -0
new file mode 100644
index 0000000..b06b60d
@@ -0,0 +1,350 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2016 Nexell
+ * Youngbok, Park <[email protected]>
+ *
+ * (C) Copyright 2019 Stefan Bosch <[email protected]>
+ */
+
+#include <common.h>
+#include <clk.h>
+#include <dm.h>
+#include <dt-structs.h>
+#include <dwmmc.h>
+#include <syscon.h>
+#include <asm/gpio.h>
+#include <asm/arch/nx_gpio.h>
+#include <asm/arch/reset.h>
+
+#define DWMCI_CLKSEL			0x09C
+#define DWMCI_SHIFT_0			0x0
+#define DWMCI_SHIFT_1			0x1
+#define DWMCI_SHIFT_2			0x2
+#define DWMCI_SHIFT_3			0x3
+#define DWMCI_SET_SAMPLE_CLK(x)	(x)
+#define DWMCI_SET_DRV_CLK(x)	((x) << 16)
+#define DWMCI_SET_DIV_RATIO(x)	((x) << 24)
+#define DWMCI_CLKCTRL			0x114
+#define NX_MMC_CLK_DELAY(x, y, a, b)	((((x) & 0xFF) << 0) |\
+					(((y) & 0x03) << 16) |\
+					(((a) & 0xFF) << 8)  |\
+					(((b) & 0x03) << 24))
+
+struct nexell_mmc_plat {
+	struct mmc_config cfg;
+	struct mmc mmc;
+};
+
+struct nexell_dwmmc_priv {
+	struct clk *clk;
+	struct dwmci_host host;
+	int fifo_size;
+	bool fifo_mode;
+	int frequency;
+	u32 min_freq;
+	u32 max_freq;
+	int d_delay;
+	int d_shift;
+	int s_delay;
+	int s_shift;
+
+};
+
+struct clk *clk_get(const char *id);
+
+static void set_pin_stat(int index, int bit, int value)
+{
+#if !defined(CONFIG_SPL_BUILD)

drivers/mmc/nexell_dw_mmc_dm.c line 67

Quoted 10 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +10 -0
+	nx_gpio_set_pad_function(index, bit, value);
+#else
+#if defined(CONFIG_ARCH_S5P4418) ||	\
+	defined(CONFIG_ARCH_S5P6818)
+
+	unsigned long base[5] = {
+		PHY_BASEADDR_GPIOA, PHY_BASEADDR_GPIOB,
+		PHY_BASEADDR_GPIOC, PHY_BASEADDR_GPIOD,
+		PHY_BASEADDR_GPIOE,
+	};

I don't understand why gpio pin is set in mmc driver?
If nexell soc will change the gpio map and function value, does it needs to add other gpio control?

Quoted 33 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +33 -0
+
+	dw_mmc_set_pin(base[index], bit, value);
+#endif
+#endif
+}
+
+static void nx_dw_mmc_set_pin(struct dwmci_host *host)
+{
+	debug("  %s(): dev_index == %d", __func__, host->dev_index);
+
+	switch (host->dev_index) {
+	case 0:
+		set_pin_stat(0, 29, 1);
+		set_pin_stat(0, 31, 1);
+		set_pin_stat(1, 1, 1);
+		set_pin_stat(1, 3, 1);
+		set_pin_stat(1, 5, 1);
+		set_pin_stat(1, 7, 1);
+		break;
+	case 1:
+		set_pin_stat(3, 22, 1);
+		set_pin_stat(3, 23, 1);
+		set_pin_stat(3, 24, 1);
+		set_pin_stat(3, 25, 1);
+		set_pin_stat(3, 26, 1);
+		set_pin_stat(3, 27, 1);
+		break;
+	case 2:
+		set_pin_stat(2, 18, 2);
+		set_pin_stat(2, 19, 2);
+		set_pin_stat(2, 20, 2);
+		set_pin_stat(2, 21, 2);
+		set_pin_stat(2, 22, 2);

drivers/mmc/nexell_dw_mmc_dm.c line 110

Quoted 10 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +10 -0
+		set_pin_stat(2, 23, 2);
+		if (host->buswidth == 8) {
+			set_pin_stat(4, 21, 2);
+			set_pin_stat(4, 22, 2);
+			set_pin_stat(4, 23, 2);
+			set_pin_stat(4, 24, 2);
+		}
+		break;
+	default:
+		debug(" is invalid!");

Is invalid..then will not work fine?

i don't check your patch fully.
Your patch doesn't control gpio with dt?
Well, i don't agree this concept. it need to get opinion how to think about this.

drivers/mmc/nexell_dw_mmc_dm.c line 119

Quoted 9 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +9 -0
+	}
+	debug("\n");
+}
+
+static void nx_dw_mmc_clksel(struct dwmci_host *host)
+{
+	u32 val;
+
+#ifdef CONFIG_BOOST_MMC

What is BOOST_MMC?

drivers/mmc/nexell_dw_mmc_dm.c line 132

Quoted 13 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +13 -0
+	val = DWMCI_SET_SAMPLE_CLK(DWMCI_SHIFT_0) |
+	    DWMCI_SET_DRV_CLK(DWMCI_SHIFT_0) | DWMCI_SET_DIV_RATIO(1);
+#else
+	val = DWMCI_SET_SAMPLE_CLK(DWMCI_SHIFT_0) |
+	    DWMCI_SET_DRV_CLK(DWMCI_SHIFT_0) | DWMCI_SET_DIV_RATIO(3);
+#endif
+
+	dwmci_writel(host, DWMCI_CLKSEL, val);
+}
+
+static void nx_dw_mmc_reset(int ch)
+{
+	int rst_id = RESET_ID_SDMMC0 + ch;

RESET_ID_SDMMC0?

Quoted 22 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +22 -0
+
+	nx_rstcon_setrst(rst_id, 0);
+	nx_rstcon_setrst(rst_id, 1);
+}
+
+static void nx_dw_mmc_clk_delay(struct udevice *dev)
+{
+	unsigned int delay;
+	struct nexell_dwmmc_priv *priv = dev_get_priv(dev);
+	struct dwmci_host *host = &priv->host;
+
+	delay = NX_MMC_CLK_DELAY(priv->d_delay,
+				 priv->d_shift, priv->s_delay, priv->s_shift);
+
+	writel(delay, (host->ioaddr + DWMCI_CLKCTRL));
+	debug("%s(): Values set: d_delay==%d, d_shift==%d, s_delay==%d, "
+	      "s_shift==%d\n", __func__, priv->d_delay, priv->d_shift,
+	      priv->s_delay, priv->s_shift);
+}
+
+static unsigned int nx_dw_mmc_get_clk(struct dwmci_host *host, uint freq)
+{

drivers/mmc/nexell_dw_mmc_dm.c line 164

Quoted 10 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +10 -0
+	struct clk *clk;
+	struct udevice *dev = host->priv;
+	struct nexell_dwmmc_priv *priv = dev_get_priv(dev);
+
+	int index = host->dev_index;
+	char name[50] = { 0, };
+
+	clk = priv->clk;
+	if (!clk) {
+		sprintf(name, "%s.%d", DEV_NAME_SDHC, index);

DEV_NAME_SDHC ???

Quoted 115 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +115 -0
+		clk = clk_get((const char *)name);
+		if (!clk)
+			return 0;
+		priv->clk = clk;
+	}
+
+	return clk_get_rate(clk) / 2;
+}
+
+static unsigned long nx_dw_mmc_set_clk(struct dwmci_host *host,
+				       unsigned int rate)
+{
+	struct clk *clk;
+	char name[50] = { 0, };
+	struct udevice *dev = host->priv;
+	struct nexell_dwmmc_priv *priv = dev_get_priv(dev);
+
+	int index = host->dev_index;
+
+	clk = priv->clk;
+	if (!clk) {
+		sprintf(name, "%s.%d", DEV_NAME_SDHC, index);
+		clk = clk_get((const char *)name);
+		if (!clk)
+			return 0;
+		priv->clk = clk;
+	}
+
+	clk_disable(clk);
+	rate = clk_set_rate(clk, rate);
+	clk_enable(clk);
+
+	return rate;
+}
+
+static int nexell_dwmmc_ofdata_to_platdata(struct udevice *dev)
+{
+	/* if (dev): *priv = dev->priv, else: *priv = NULL */
+	struct nexell_dwmmc_priv *priv = dev_get_priv(dev);
+	struct dwmci_host *host = &priv->host;
+	int val = -1;
+
+	debug("%s()\n", __func__);
+
+	host->name = dev->name;
+	host->ioaddr = dev_read_addr_ptr(dev);
+
+	val = dev_read_u32_default(dev, "nexell,bus-width", -1);
+	if (val < 0) {
+		debug("  'nexell,bus-width' missing/invalid!\n");
+		return -EINVAL;
+	}
+	host->buswidth = val;
+	host->get_mmc_clk = nx_dw_mmc_get_clk;
+	host->clksel = nx_dw_mmc_clksel;
+	host->priv = dev;
+
+	val = dev_read_u32_default(dev, "index", -1);
+	if (val < 0) {
+		debug("  'index' missing/invalid!\n");
+		return -EINVAL;
+	}
+	host->dev_index = val;
+
+	val = dev_read_u32_default(dev, "fifo-size", 0x20);
+	if (val <= 0) {
+		debug("  'fifo-size' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->fifo_size = val;
+
+	priv->fifo_mode = dev_read_bool(dev, "fifo-mode");
+
+	val = dev_read_u32_default(dev, "frequency", -1);
+	if (val < 0) {
+		debug("  'frequency' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->frequency = val;
+
+	val = dev_read_u32_default(dev, "max-frequency", -1);
+	if (val < 0) {
+		debug("  'max-frequency' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->max_freq = val;
+	priv->min_freq = 400000;  /* 400 kHz */
+
+	val = dev_read_u32_default(dev, "nexell,drive_dly", -1);
+	if (val < 0) {
+		debug("  'nexell,drive_dly' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->d_delay = val;
+
+	val = dev_read_u32_default(dev, "nexell,drive_shift", -1);
+	if (val < 0) {
+		debug("  'nexell,drive_shift' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->d_shift = val;
+
+	val = dev_read_u32_default(dev, "nexell,sample_dly", -1);
+	if (val < 0) {
+		debug("  'nexell,sample_dly' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->s_delay = val;
+
+	val = dev_read_u32_default(dev, "nexell,sample_shift", -1);
+	if (val < 0) {
+		debug("  'nexell,sample_shift' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->s_shift = val;

drivers/mmc/nexell_dw_mmc_dm.c line 289

Quoted 10 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +10 -0
+
+	debug("  index==%d, name==%s, ioaddr==0x%08x, buswidth==%d, "
+		  "fifo_size==%d, fifo_mode==%d, frequency==%d\n",
+		  host->dev_index, host->name, (u32)host->ioaddr,
+		  host->buswidth, priv->fifo_size, priv->fifo_mode,
+		  priv->frequency);
+	debug("  min_freq==%d, max_freq==%d, delay: "
+		  "0x%02x:0x%02x:0x%02x:0x%02x\n",
+		  priv->min_freq, priv->max_freq, priv->d_delay,
+		  priv->d_shift, priv->s_delay, priv->s_shift);

entirely not readable. not need to assign again with val.

priv->s_deley = dev_read_u32_default();

drivers/mmc/nexell_dw_mmc_dm.c line 302

Quoted 13 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +13 -0
+
+	return 0;
+}
+
+static int nexell_dwmmc_probe(struct udevice *dev)
+{
+	struct nexell_mmc_plat *plat = dev_get_platdata(dev);
+	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
+	struct nexell_dwmmc_priv *priv = dev_get_priv(dev);
+	struct dwmci_host *host = &priv->host;
+	struct udevice *pwr_dev __maybe_unused;
+
+	debug("%s():\n", __func__);

Don't add unnecessary debug code. it's meaningless even if it's enabled.

Well, i didn't check other patches..but i think that your patches seems to based on older u-boot version.

Best Regards,
Jaehoon Chung

Quoted 49 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +48 -0
+
+	host->fifoth_val = MSIZE(0x2) |
+		RX_WMARK(priv->fifo_size / 2 - 1) |
+		TX_WMARK(priv->fifo_size / 2);
+
+	host->fifo_mode = priv->fifo_mode;
+
+	dwmci_setup_cfg(&plat->cfg, host, priv->max_freq, priv->min_freq);
+	host->mmc = &plat->mmc;
+	host->mmc->priv = &priv->host;
+	host->mmc->dev = dev;
+	upriv->mmc = host->mmc;
+
+	nx_dw_mmc_set_pin(host);
+
+	debug("  nx_dw_mmc_set_clk(host, frequency * 4 == %d)\n",
+	      priv->frequency * 4);
+	nx_dw_mmc_set_clk(host, priv->frequency * 4);
+
+	nx_dw_mmc_reset(host->dev_index);
+	nx_dw_mmc_clk_delay(dev);
+
+	return dwmci_probe(dev);
+}
+
+static int nexell_dwmmc_bind(struct udevice *dev)
+{
+	struct nexell_mmc_plat *plat = dev_get_platdata(dev);
+
+	return dwmci_bind(dev, &plat->mmc, &plat->cfg);
+}
+
+static const struct udevice_id nexell_dwmmc_ids[] = {
+	{ .compatible = "nexell,nexell-dwmmc" },
+	{ }
+};
+
+U_BOOT_DRIVER(nexell_dwmmc_drv) = {
+	.name		= "nexell_dwmmc",
+	.id		= UCLASS_MMC,
+	.of_match	= nexell_dwmmc_ids,
+	.ofdata_to_platdata = nexell_dwmmc_ofdata_to_platdata,
+	.ops		= &dm_dwmci_ops,
+	.bind		= nexell_dwmmc_bind,
+	.probe		= nexell_dwmmc_probe,
+	.priv_auto_alloc_size = sizeof(struct nexell_dwmmc_priv),
+	.platdata_auto_alloc_size = sizeof(struct nexell_mmc_plat),
+};
author
#10 lore raw

RFC PATCH v2 5/13 mmc: add nexell driver

Hi,

thanks a lot for your reply. As you already guessed I have ported the outdated U-Boot from FriendlyARM, see:
https://github.com/friendlyarm/u-boot/tree/nanopi2-v2016.01

The original MMC-driver has been nexell_dw_mmc.c, so I renamed it to nexell_dw_mmc_dm.c after changing to DM.

I will have a closer look at your suggestions and give you feedback ASAP.

Regards
Stefan Bosch

Am 02.04.20 um 13:03 schrieb Jaehoon Chung:

Quoted 447 lines

Hi,

Quoted 2 lines · Stefan Bosch

Changes in relation to FriendlyARM's U-Boot nanopi2-v2016.01:
- mmc: nexell_dw_mmc.c changed to nexell_dw_mmc_dm.c (switched to DM).

It doesn't need to add postfix as _dm.

Quoted 19 lines

---

Changes in v2:
- commit "i2c: mmc: add nexell driver (gpio, i2c, mmc, pwm)" splitted into separate commits for gpio, i2c, mmc, pwm.

  drivers/mmc/Kconfig            |   6 +
  drivers/mmc/Makefile           |   1 +
  drivers/mmc/nexell_dw_mmc_dm.c | 350 +++++++++++++++++++++++++++++++++++++++++
  3 files changed, 357 insertions(+)

create mode 100644 drivers/mmc/nexell_dw_mmc_dm.c

drivers/mmc/Kconfig +0 -0
index 2f0eedc..bb8e7c0 100644

drivers/mmc/Kconfig config MMC_DW_SNPS · line 260

Quoted 8 lines
drivers/mmc/Kconfig +5 -0
@@ -253,6 +253,12 @@ config MMC_DW_SNPS
  	  This selects support for Synopsys DesignWare Memory Card Interface driver
  	  extensions used in various Synopsys ARC devboards.
 
+config NEXELL_DWMMC
+	bool "Nexell SD/MMC controller support"
+	depends on ARCH_NEXELL
+	depends on MMC_DW
+	default y

Not depends on DM_MMC?

Quoted 79 lines
drivers/mmc/Kconfig +1 -0
+
  config MMC_MESON_GX
  	bool "Meson GX EMMC controller support"
  	depends on DM_MMC && BLK && ARCH_MESON
drivers/mmc/Makefile +1 -0
index 9c1f8e5..a7b5a7b 100644
@@ -43,6 +43,7 @@ obj-$(CONFIG_SH_MMCIF) += sh_mmcif.o
  obj-$(CONFIG_SH_SDHI) += sh_sdhi.o
  obj-$(CONFIG_STM32_SDMMC2) += stm32_sdmmc2.o
  obj-$(CONFIG_JZ47XX_MMC) += jz_mmc.o
+obj-$(CONFIG_NEXELL_DWMMC) += nexell_dw_mmc_dm.o
 
  # SDHCI
  obj-$(CONFIG_MMC_SDHCI)			+= sdhci.o
drivers/mmc/nexell_dw_mmc_dm.c new file +57 -0
new file mode 100644
index 0000000..b06b60d
@@ -0,0 +1,350 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2016 Nexell
+ * Youngbok, Park <[email protected]>
+ *
+ * (C) Copyright 2019 Stefan Bosch <[email protected]>
+ */
+
+#include <common.h>
+#include <clk.h>
+#include <dm.h>
+#include <dt-structs.h>
+#include <dwmmc.h>
+#include <syscon.h>
+#include <asm/gpio.h>
+#include <asm/arch/nx_gpio.h>
+#include <asm/arch/reset.h>
+
+#define DWMCI_CLKSEL			0x09C
+#define DWMCI_SHIFT_0			0x0
+#define DWMCI_SHIFT_1			0x1
+#define DWMCI_SHIFT_2			0x2
+#define DWMCI_SHIFT_3			0x3
+#define DWMCI_SET_SAMPLE_CLK(x)	(x)
+#define DWMCI_SET_DRV_CLK(x)	((x) << 16)
+#define DWMCI_SET_DIV_RATIO(x)	((x) << 24)
+#define DWMCI_CLKCTRL			0x114
+#define NX_MMC_CLK_DELAY(x, y, a, b)	((((x) & 0xFF) << 0) |\
+					(((y) & 0x03) << 16) |\
+					(((a) & 0xFF) << 8)  |\
+					(((b) & 0x03) << 24))
+
+struct nexell_mmc_plat {
+	struct mmc_config cfg;
+	struct mmc mmc;
+};
+
+struct nexell_dwmmc_priv {
+	struct clk *clk;
+	struct dwmci_host host;
+	int fifo_size;
+	bool fifo_mode;
+	int frequency;
+	u32 min_freq;
+	u32 max_freq;
+	int d_delay;
+	int d_shift;
+	int s_delay;
+	int s_shift;
+
+};
+
+struct clk *clk_get(const char *id);
+
+static void set_pin_stat(int index, int bit, int value)
+{
+#if !defined(CONFIG_SPL_BUILD)

drivers/mmc/nexell_dw_mmc_dm.c line 67

Quoted 10 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +10 -0
+	nx_gpio_set_pad_function(index, bit, value);
+#else
+#if defined(CONFIG_ARCH_S5P4418) ||	\
+	defined(CONFIG_ARCH_S5P6818)
+
+	unsigned long base[5] = {
+		PHY_BASEADDR_GPIOA, PHY_BASEADDR_GPIOB,
+		PHY_BASEADDR_GPIOC, PHY_BASEADDR_GPIOD,
+		PHY_BASEADDR_GPIOE,
+	};

I don't understand why gpio pin is set in mmc driver?
If nexell soc will change the gpio map and function value, does it needs to add other gpio control?

Quoted 33 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +33 -0
+
+	dw_mmc_set_pin(base[index], bit, value);
+#endif
+#endif
+}
+
+static void nx_dw_mmc_set_pin(struct dwmci_host *host)
+{
+	debug("  %s(): dev_index == %d", __func__, host->dev_index);
+
+	switch (host->dev_index) {
+	case 0:
+		set_pin_stat(0, 29, 1);
+		set_pin_stat(0, 31, 1);
+		set_pin_stat(1, 1, 1);
+		set_pin_stat(1, 3, 1);
+		set_pin_stat(1, 5, 1);
+		set_pin_stat(1, 7, 1);
+		break;
+	case 1:
+		set_pin_stat(3, 22, 1);
+		set_pin_stat(3, 23, 1);
+		set_pin_stat(3, 24, 1);
+		set_pin_stat(3, 25, 1);
+		set_pin_stat(3, 26, 1);
+		set_pin_stat(3, 27, 1);
+		break;
+	case 2:
+		set_pin_stat(2, 18, 2);
+		set_pin_stat(2, 19, 2);
+		set_pin_stat(2, 20, 2);
+		set_pin_stat(2, 21, 2);
+		set_pin_stat(2, 22, 2);

drivers/mmc/nexell_dw_mmc_dm.c line 110

Quoted 10 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +10 -0
+		set_pin_stat(2, 23, 2);
+		if (host->buswidth == 8) {
+			set_pin_stat(4, 21, 2);
+			set_pin_stat(4, 22, 2);
+			set_pin_stat(4, 23, 2);
+			set_pin_stat(4, 24, 2);
+		}
+		break;
+	default:
+		debug(" is invalid!");

Is invalid..then will not work fine?

i don't check your patch fully.
Your patch doesn't control gpio with dt?
Well, i don't agree this concept. it need to get opinion how to think about this.

drivers/mmc/nexell_dw_mmc_dm.c line 119

Quoted 9 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +9 -0
+	}
+	debug("\n");
+}
+
+static void nx_dw_mmc_clksel(struct dwmci_host *host)
+{
+	u32 val;
+
+#ifdef CONFIG_BOOST_MMC

What is BOOST_MMC?

drivers/mmc/nexell_dw_mmc_dm.c line 132

Quoted 13 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +13 -0
+	val = DWMCI_SET_SAMPLE_CLK(DWMCI_SHIFT_0) |
+	    DWMCI_SET_DRV_CLK(DWMCI_SHIFT_0) | DWMCI_SET_DIV_RATIO(1);
+#else
+	val = DWMCI_SET_SAMPLE_CLK(DWMCI_SHIFT_0) |
+	    DWMCI_SET_DRV_CLK(DWMCI_SHIFT_0) | DWMCI_SET_DIV_RATIO(3);
+#endif
+
+	dwmci_writel(host, DWMCI_CLKSEL, val);
+}
+
+static void nx_dw_mmc_reset(int ch)
+{
+	int rst_id = RESET_ID_SDMMC0 + ch;

RESET_ID_SDMMC0?

Quoted 22 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +22 -0
+
+	nx_rstcon_setrst(rst_id, 0);
+	nx_rstcon_setrst(rst_id, 1);
+}
+
+static void nx_dw_mmc_clk_delay(struct udevice *dev)
+{
+	unsigned int delay;
+	struct nexell_dwmmc_priv *priv = dev_get_priv(dev);
+	struct dwmci_host *host = &priv->host;
+
+	delay = NX_MMC_CLK_DELAY(priv->d_delay,
+				 priv->d_shift, priv->s_delay, priv->s_shift);
+
+	writel(delay, (host->ioaddr + DWMCI_CLKCTRL));
+	debug("%s(): Values set: d_delay==%d, d_shift==%d, s_delay==%d, "
+	      "s_shift==%d\n", __func__, priv->d_delay, priv->d_shift,
+	      priv->s_delay, priv->s_shift);
+}
+
+static unsigned int nx_dw_mmc_get_clk(struct dwmci_host *host, uint freq)
+{

drivers/mmc/nexell_dw_mmc_dm.c line 164

Quoted 10 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +10 -0
+	struct clk *clk;
+	struct udevice *dev = host->priv;
+	struct nexell_dwmmc_priv *priv = dev_get_priv(dev);
+
+	int index = host->dev_index;
+	char name[50] = { 0, };
+
+	clk = priv->clk;
+	if (!clk) {
+		sprintf(name, "%s.%d", DEV_NAME_SDHC, index);

DEV_NAME_SDHC ???

Quoted 115 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +115 -0
+		clk = clk_get((const char *)name);
+		if (!clk)
+			return 0;
+		priv->clk = clk;
+	}
+
+	return clk_get_rate(clk) / 2;
+}
+
+static unsigned long nx_dw_mmc_set_clk(struct dwmci_host *host,
+				       unsigned int rate)
+{
+	struct clk *clk;
+	char name[50] = { 0, };
+	struct udevice *dev = host->priv;
+	struct nexell_dwmmc_priv *priv = dev_get_priv(dev);
+
+	int index = host->dev_index;
+
+	clk = priv->clk;
+	if (!clk) {
+		sprintf(name, "%s.%d", DEV_NAME_SDHC, index);
+		clk = clk_get((const char *)name);
+		if (!clk)
+			return 0;
+		priv->clk = clk;
+	}
+
+	clk_disable(clk);
+	rate = clk_set_rate(clk, rate);
+	clk_enable(clk);
+
+	return rate;
+}
+
+static int nexell_dwmmc_ofdata_to_platdata(struct udevice *dev)
+{
+	/* if (dev): *priv = dev->priv, else: *priv = NULL */
+	struct nexell_dwmmc_priv *priv = dev_get_priv(dev);
+	struct dwmci_host *host = &priv->host;
+	int val = -1;
+
+	debug("%s()\n", __func__);
+
+	host->name = dev->name;
+	host->ioaddr = dev_read_addr_ptr(dev);
+
+	val = dev_read_u32_default(dev, "nexell,bus-width", -1);
+	if (val < 0) {
+		debug("  'nexell,bus-width' missing/invalid!\n");
+		return -EINVAL;
+	}
+	host->buswidth = val;
+	host->get_mmc_clk = nx_dw_mmc_get_clk;
+	host->clksel = nx_dw_mmc_clksel;
+	host->priv = dev;
+
+	val = dev_read_u32_default(dev, "index", -1);
+	if (val < 0) {
+		debug("  'index' missing/invalid!\n");
+		return -EINVAL;
+	}
+	host->dev_index = val;
+
+	val = dev_read_u32_default(dev, "fifo-size", 0x20);
+	if (val <= 0) {
+		debug("  'fifo-size' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->fifo_size = val;
+
+	priv->fifo_mode = dev_read_bool(dev, "fifo-mode");
+
+	val = dev_read_u32_default(dev, "frequency", -1);
+	if (val < 0) {
+		debug("  'frequency' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->frequency = val;
+
+	val = dev_read_u32_default(dev, "max-frequency", -1);
+	if (val < 0) {
+		debug("  'max-frequency' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->max_freq = val;
+	priv->min_freq = 400000;  /* 400 kHz */
+
+	val = dev_read_u32_default(dev, "nexell,drive_dly", -1);
+	if (val < 0) {
+		debug("  'nexell,drive_dly' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->d_delay = val;
+
+	val = dev_read_u32_default(dev, "nexell,drive_shift", -1);
+	if (val < 0) {
+		debug("  'nexell,drive_shift' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->d_shift = val;
+
+	val = dev_read_u32_default(dev, "nexell,sample_dly", -1);
+	if (val < 0) {
+		debug("  'nexell,sample_dly' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->s_delay = val;
+
+	val = dev_read_u32_default(dev, "nexell,sample_shift", -1);
+	if (val < 0) {
+		debug("  'nexell,sample_shift' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->s_shift = val;

drivers/mmc/nexell_dw_mmc_dm.c line 289

Quoted 10 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +10 -0
+
+	debug("  index==%d, name==%s, ioaddr==0x%08x, buswidth==%d, "
+		  "fifo_size==%d, fifo_mode==%d, frequency==%d\n",
+		  host->dev_index, host->name, (u32)host->ioaddr,
+		  host->buswidth, priv->fifo_size, priv->fifo_mode,
+		  priv->frequency);
+	debug("  min_freq==%d, max_freq==%d, delay: "
+		  "0x%02x:0x%02x:0x%02x:0x%02x\n",
+		  priv->min_freq, priv->max_freq, priv->d_delay,
+		  priv->d_shift, priv->s_delay, priv->s_shift);

entirely not readable. not need to assign again with val.

priv->s_deley = dev_read_u32_default();

drivers/mmc/nexell_dw_mmc_dm.c line 302

Quoted 13 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +13 -0
+
+	return 0;
+}
+
+static int nexell_dwmmc_probe(struct udevice *dev)
+{
+	struct nexell_mmc_plat *plat = dev_get_platdata(dev);
+	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
+	struct nexell_dwmmc_priv *priv = dev_get_priv(dev);
+	struct dwmci_host *host = &priv->host;
+	struct udevice *pwr_dev __maybe_unused;
+
+	debug("%s():\n", __func__);

Don't add unnecessary debug code. it's meaningless even if it's enabled.

Well, i didn't check other patches..but i think that your patches seems to based on older u-boot version.

Best Regards,
Jaehoon Chung

Quoted 49 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +48 -0
+
+	host->fifoth_val = MSIZE(0x2) |
+		RX_WMARK(priv->fifo_size / 2 - 1) |
+		TX_WMARK(priv->fifo_size / 2);
+
+	host->fifo_mode = priv->fifo_mode;
+
+	dwmci_setup_cfg(&plat->cfg, host, priv->max_freq, priv->min_freq);
+	host->mmc = &plat->mmc;
+	host->mmc->priv = &priv->host;
+	host->mmc->dev = dev;
+	upriv->mmc = host->mmc;
+
+	nx_dw_mmc_set_pin(host);
+
+	debug("  nx_dw_mmc_set_clk(host, frequency * 4 == %d)\n",
+	      priv->frequency * 4);
+	nx_dw_mmc_set_clk(host, priv->frequency * 4);
+
+	nx_dw_mmc_reset(host->dev_index);
+	nx_dw_mmc_clk_delay(dev);
+
+	return dwmci_probe(dev);
+}
+
+static int nexell_dwmmc_bind(struct udevice *dev)
+{
+	struct nexell_mmc_plat *plat = dev_get_platdata(dev);
+
+	return dwmci_bind(dev, &plat->mmc, &plat->cfg);
+}
+
+static const struct udevice_id nexell_dwmmc_ids[] = {
+	{ .compatible = "nexell,nexell-dwmmc" },
+	{ }
+};
+
+U_BOOT_DRIVER(nexell_dwmmc_drv) = {
+	.name		= "nexell_dwmmc",
+	.id		= UCLASS_MMC,
+	.of_match	= nexell_dwmmc_ids,
+	.ofdata_to_platdata = nexell_dwmmc_ofdata_to_platdata,
+	.ops		= &dm_dwmci_ops,
+	.bind		= nexell_dwmmc_bind,
+	.probe		= nexell_dwmmc_probe,
+	.priv_auto_alloc_size = sizeof(struct nexell_dwmmc_priv),
+	.platdata_auto_alloc_size = sizeof(struct nexell_mmc_plat),
+};
author
#11 lore raw

RFC PATCH v2 5/13 mmc: add nexell driver

In reply to Jaehoon Chung

Hi,

see below my answers to your questions.

Regards
Stefan Bosch

Hi,

thanks a lot for your reply. As you already guessed I have ported the outdated U-Boot from FriendlyARM, see:
https://github.com/friendlyarm/u-boot/tree/nanopi2-v2016.01

The original MMC-driver has been nexell_dw_mmc.c, so I renamed it to nexell_dw_mmc_dm.c after changing to DM.

I will have a closer look at your suggestions and give you feedback ASAP.

Regards
Stefan Bosch

Am 02.04.20 um 13:03 schrieb Jaehoon Chung:

Quoted 8 lines

Hi,

Quoted 2 lines · Stefan Bosch

Changes in relation to FriendlyARM's U-Boot nanopi2-v2016.01:
- mmc: nexell_dw_mmc.c changed to nexell_dw_mmc_dm.c (switched to DM).

It doesn't need to add postfix as _dm.

Ok, I have renamed it to nexell_dw_mmc.c.

Quoted 22 lines
Quoted 22 lines

---

Changes in v2:
- commit "i2c: mmc: add nexell driver (gpio, i2c, mmc, pwm)" splitted into separate commits for gpio, i2c, mmc, pwm.

  drivers/mmc/Kconfig            |   6 +
  drivers/mmc/Makefile           |   1 +
  drivers/mmc/nexell_dw_mmc_dm.c | 350 +++++++++++++++++++++++++++++++++++++++++
  3 files changed, 357 insertions(+)

create mode 100644 drivers/mmc/nexell_dw_mmc_dm.c

drivers/mmc/Kconfig +0 -0
index 2f0eedc..bb8e7c0 100644
@@ -253,6 +253,12 @@ config MMC_DW_SNPS
  	  This selects support for Synopsys DesignWare Memory Card Interface driver
  	  extensions used in various Synopsys ARC devboards.
 
Quoted 8 lines

drivers/mmc/Kconfig config MMC_DW_SNPS · line 260

Quoted 5 lines
drivers/mmc/Kconfig +5 -0
+config NEXELL_DWMMC
+	bool "Nexell SD/MMC controller support"
+	depends on ARCH_NEXELL
+	depends on MMC_DW
+	default y

Not depends on DM_MMC?

You are right, I have inserted "depends on DM_MMC". I missed this when changing to DM.

Quoted 139 lines
Quoted 79 lines
drivers/mmc/Kconfig +1 -0
+
  config MMC_MESON_GX
  	bool "Meson GX EMMC controller support"
  	depends on DM_MMC && BLK && ARCH_MESON
drivers/mmc/Makefile +1 -0
index 9c1f8e5..a7b5a7b 100644
@@ -43,6 +43,7 @@ obj-$(CONFIG_SH_MMCIF) += sh_mmcif.o
  obj-$(CONFIG_SH_SDHI) += sh_sdhi.o
  obj-$(CONFIG_STM32_SDMMC2) += stm32_sdmmc2.o
  obj-$(CONFIG_JZ47XX_MMC) += jz_mmc.o
+obj-$(CONFIG_NEXELL_DWMMC) += nexell_dw_mmc_dm.o
 
  # SDHCI
  obj-$(CONFIG_MMC_SDHCI)			+= sdhci.o
drivers/mmc/nexell_dw_mmc_dm.c new file +57 -0
new file mode 100644
index 0000000..b06b60d
@@ -0,0 +1,350 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2016 Nexell
+ * Youngbok, Park <[email protected]>
+ *
+ * (C) Copyright 2019 Stefan Bosch <[email protected]>
+ */
+
+#include <common.h>
+#include <clk.h>
+#include <dm.h>
+#include <dt-structs.h>
+#include <dwmmc.h>
+#include <syscon.h>
+#include <asm/gpio.h>
+#include <asm/arch/nx_gpio.h>
+#include <asm/arch/reset.h>
+
+#define DWMCI_CLKSEL			0x09C
+#define DWMCI_SHIFT_0			0x0
+#define DWMCI_SHIFT_1			0x1
+#define DWMCI_SHIFT_2			0x2
+#define DWMCI_SHIFT_3			0x3
+#define DWMCI_SET_SAMPLE_CLK(x)	(x)
+#define DWMCI_SET_DRV_CLK(x)	((x) << 16)
+#define DWMCI_SET_DIV_RATIO(x)	((x) << 24)
+#define DWMCI_CLKCTRL			0x114
+#define NX_MMC_CLK_DELAY(x, y, a, b)	((((x) & 0xFF) << 0) |\
+					(((y) & 0x03) << 16) |\
+					(((a) & 0xFF) << 8)  |\
+					(((b) & 0x03) << 24))
+
+struct nexell_mmc_plat {
+	struct mmc_config cfg;
+	struct mmc mmc;
+};
+
+struct nexell_dwmmc_priv {
+	struct clk *clk;
+	struct dwmci_host host;
+	int fifo_size;
+	bool fifo_mode;
+	int frequency;
+	u32 min_freq;
+	u32 max_freq;
+	int d_delay;
+	int d_shift;
+	int s_delay;
+	int s_shift;
+
+};
+
+struct clk *clk_get(const char *id);
+
+static void set_pin_stat(int index, int bit, int value)
+{
+#if !defined(CONFIG_SPL_BUILD)

drivers/mmc/nexell_dw_mmc_dm.c line 67

Quoted 10 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +10 -0
+	nx_gpio_set_pad_function(index, bit, value);
+#else
+#if defined(CONFIG_ARCH_S5P4418) ||	\
+	defined(CONFIG_ARCH_S5P6818)
+
+	unsigned long base[5] = {
+		PHY_BASEADDR_GPIOA, PHY_BASEADDR_GPIOB,
+		PHY_BASEADDR_GPIOC, PHY_BASEADDR_GPIOD,
+		PHY_BASEADDR_GPIOE,
+	};

I don't understand why gpio pin is set in mmc driver?
If nexell soc will change the gpio map and function value, does it needs to add other gpio control?

Quoted 33 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +33 -0
+
+	dw_mmc_set_pin(base[index], bit, value);
+#endif
+#endif
+}
+
+static void nx_dw_mmc_set_pin(struct dwmci_host *host)
+{
+	debug("  %s(): dev_index == %d", __func__, host->dev_index);
+
+	switch (host->dev_index) {
+	case 0:
+		set_pin_stat(0, 29, 1);
+		set_pin_stat(0, 31, 1);
+		set_pin_stat(1, 1, 1);
+		set_pin_stat(1, 3, 1);
+		set_pin_stat(1, 5, 1);
+		set_pin_stat(1, 7, 1);
+		break;
+	case 1:
+		set_pin_stat(3, 22, 1);
+		set_pin_stat(3, 23, 1);
+		set_pin_stat(3, 24, 1);
+		set_pin_stat(3, 25, 1);
+		set_pin_stat(3, 26, 1);
+		set_pin_stat(3, 27, 1);
+		break;
+	case 2:
+		set_pin_stat(2, 18, 2);
+		set_pin_stat(2, 19, 2);
+		set_pin_stat(2, 20, 2);
+		set_pin_stat(2, 21, 2);
+		set_pin_stat(2, 22, 2);

drivers/mmc/nexell_dw_mmc_dm.c line 110

Quoted 10 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +10 -0
+		set_pin_stat(2, 23, 2);
+		if (host->buswidth == 8) {
+			set_pin_stat(4, 21, 2);
+			set_pin_stat(4, 22, 2);
+			set_pin_stat(4, 23, 2);
+			set_pin_stat(4, 24, 2);
+		}
+		break;
+	default:
+		debug(" is invalid!");

Is invalid..then will not work fine?

Quoted 4 lines

i don't check your patch fully.
Your patch doesn't control gpio with dt?
Well, i don't agree this concept. it need to get opinion how to think about this.

Nexell has not implemented an pinctrl-driver, so the GPIOs are switched to MMC-function here.
I have removed the above "default", now I check for a valid dev_index in nexell_dwmmc_ofdata_to_platdata().

Quoted 12 lines

drivers/mmc/nexell_dw_mmc_dm.c line 119

Quoted 9 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +9 -0
+	}
+	debug("\n");
+}
+
+static void nx_dw_mmc_clksel(struct dwmci_host *host)
+{
+	u32 val;
+
+#ifdef CONFIG_BOOST_MMC

What is BOOST_MMC?

This influences what value is written to register offset 0x9C of the MMC-controller. Unfortunatelly, I can not give you more info because this register is indicated as "Reserved" in the S5P4418-datasheet I have access to (Revision 0.10 from October 2014).

Quoted 7 lines
Quoted 7 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +7 -0
+	val = DWMCI_SET_SAMPLE_CLK(DWMCI_SHIFT_0) |
+	    DWMCI_SET_DRV_CLK(DWMCI_SHIFT_0) | DWMCI_SET_DIV_RATIO(1);
+#else
+	val = DWMCI_SET_SAMPLE_CLK(DWMCI_SHIFT_0) |
+	    DWMCI_SET_DRV_CLK(DWMCI_SHIFT_0) | DWMCI_SET_DIV_RATIO(3);
+#endif
+
Quoted 9 lines

drivers/mmc/nexell_dw_mmc_dm.c line 132

Quoted 6 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +6 -0
+	dwmci_writel(host, DWMCI_CLKSEL, val);
+}
+
+static void nx_dw_mmc_reset(int ch)
+{
+	int rst_id = RESET_ID_SDMMC0 + ch;

RESET_ID_SDMMC0?

This is defined in arch/arm/include/asm/arch/nexell.h.

Quoted 26 lines
Quoted 26 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +26 -0
+
+	nx_rstcon_setrst(rst_id, 0);
+	nx_rstcon_setrst(rst_id, 1);
+}
+
+static void nx_dw_mmc_clk_delay(struct udevice *dev)
+{
+	unsigned int delay;
+	struct nexell_dwmmc_priv *priv = dev_get_priv(dev);
+	struct dwmci_host *host = &priv->host;
+
+	delay = NX_MMC_CLK_DELAY(priv->d_delay,
+				 priv->d_shift, priv->s_delay, priv->s_shift);
+
+	writel(delay, (host->ioaddr + DWMCI_CLKCTRL));
+	debug("%s(): Values set: d_delay==%d, d_shift==%d, s_delay==%d, "
+	      "s_shift==%d\n", __func__, priv->d_delay, priv->d_shift,
+	      priv->s_delay, priv->s_shift);
+}
+
+static unsigned int nx_dw_mmc_get_clk(struct dwmci_host *host, uint freq)
+{
+	struct clk *clk;
+	struct udevice *dev = host->priv;
+	struct nexell_dwmmc_priv *priv = dev_get_priv(dev);
+
Quoted 9 lines

drivers/mmc/nexell_dw_mmc_dm.c line 164

Quoted 6 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +6 -0
+	int index = host->dev_index;
+	char name[50] = { 0, };
+
+	clk = priv->clk;
+	if (!clk) {
+		sprintf(name, "%s.%d", DEV_NAME_SDHC, index);

DEV_NAME_SDHC ???

This is also defined in arch/arm/include/asm/arch/nexell.h: "nx-sdhc"

Quoted 128 lines
Quoted 115 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +115 -0
+		clk = clk_get((const char *)name);
+		if (!clk)
+			return 0;
+		priv->clk = clk;
+	}
+
+	return clk_get_rate(clk) / 2;
+}
+
+static unsigned long nx_dw_mmc_set_clk(struct dwmci_host *host,
+				       unsigned int rate)
+{
+	struct clk *clk;
+	char name[50] = { 0, };
+	struct udevice *dev = host->priv;
+	struct nexell_dwmmc_priv *priv = dev_get_priv(dev);
+
+	int index = host->dev_index;
+
+	clk = priv->clk;
+	if (!clk) {
+		sprintf(name, "%s.%d", DEV_NAME_SDHC, index);
+		clk = clk_get((const char *)name);
+		if (!clk)
+			return 0;
+		priv->clk = clk;
+	}
+
+	clk_disable(clk);
+	rate = clk_set_rate(clk, rate);
+	clk_enable(clk);
+
+	return rate;
+}
+
+static int nexell_dwmmc_ofdata_to_platdata(struct udevice *dev)
+{
+	/* if (dev): *priv = dev->priv, else: *priv = NULL */
+	struct nexell_dwmmc_priv *priv = dev_get_priv(dev);
+	struct dwmci_host *host = &priv->host;
+	int val = -1;
+
+	debug("%s()\n", __func__);
+
+	host->name = dev->name;
+	host->ioaddr = dev_read_addr_ptr(dev);
+
+	val = dev_read_u32_default(dev, "nexell,bus-width", -1);
+	if (val < 0) {
+		debug("  'nexell,bus-width' missing/invalid!\n");
+		return -EINVAL;
+	}
+	host->buswidth = val;
+	host->get_mmc_clk = nx_dw_mmc_get_clk;
+	host->clksel = nx_dw_mmc_clksel;
+	host->priv = dev;
+
+	val = dev_read_u32_default(dev, "index", -1);
+	if (val < 0) {
+		debug("  'index' missing/invalid!\n");
+		return -EINVAL;
+	}
+	host->dev_index = val;
+
+	val = dev_read_u32_default(dev, "fifo-size", 0x20);
+	if (val <= 0) {
+		debug("  'fifo-size' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->fifo_size = val;
+
+	priv->fifo_mode = dev_read_bool(dev, "fifo-mode");
+
+	val = dev_read_u32_default(dev, "frequency", -1);
+	if (val < 0) {
+		debug("  'frequency' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->frequency = val;
+
+	val = dev_read_u32_default(dev, "max-frequency", -1);
+	if (val < 0) {
+		debug("  'max-frequency' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->max_freq = val;
+	priv->min_freq = 400000;  /* 400 kHz */
+
+	val = dev_read_u32_default(dev, "nexell,drive_dly", -1);
+	if (val < 0) {
+		debug("  'nexell,drive_dly' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->d_delay = val;
+
+	val = dev_read_u32_default(dev, "nexell,drive_shift", -1);
+	if (val < 0) {
+		debug("  'nexell,drive_shift' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->d_shift = val;
+
+	val = dev_read_u32_default(dev, "nexell,sample_dly", -1);
+	if (val < 0) {
+		debug("  'nexell,sample_dly' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->s_delay = val;
+
+	val = dev_read_u32_default(dev, "nexell,sample_shift", -1);
+	if (val < 0) {
+		debug("  'nexell,sample_shift' missing/invalid!\n");
+		return -EINVAL;
+	}
+	priv->s_shift = val;

drivers/mmc/nexell_dw_mmc_dm.c line 289

Quoted 10 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +10 -0
+
+	debug("  index==%d, name==%s, ioaddr==0x%08x, buswidth==%d, "
+		  "fifo_size==%d, fifo_mode==%d, frequency==%d\n",
+		  host->dev_index, host->name, (u32)host->ioaddr,
+		  host->buswidth, priv->fifo_size, priv->fifo_mode,
+		  priv->frequency);
+	debug("  min_freq==%d, max_freq==%d, delay: "
+		  "0x%02x:0x%02x:0x%02x:0x%02x\n",
+		  priv->min_freq, priv->max_freq, priv->d_delay,
+		  priv->d_shift, priv->s_delay, priv->s_shift);

entirely not readable. not need to assign again with val.

Quoted 3 lines

priv->s_deley = dev_read_u32_default();

I have reworked nexell_dwmmc_ofdata_to_platdata(), i.e. valid default values are used now (where possible) and the appropriate if-blocks have been removed.

Quoted 7 lines
Quoted 7 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +7 -0
+
+	return 0;
+}
+
+static int nexell_dwmmc_probe(struct udevice *dev)
+{
+	struct nexell_mmc_plat *plat = dev_get_platdata(dev);
Quoted 9 lines

drivers/mmc/nexell_dw_mmc_dm.c line 302

Quoted 6 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +6 -0
+	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
+	struct nexell_dwmmc_priv *priv = dev_get_priv(dev);
+	struct dwmci_host *host = &priv->host;
+	struct udevice *pwr_dev __maybe_unused;
+
+	debug("%s():\n", __func__);

Don't add unnecessary debug code. it's meaningless even if it's enabled.

Ok, I have removed this debug code.

Quoted 56 lines

Well, i didn't check other patches..but i think that your patches seems to based on older u-boot version.

Best Regards,
Jaehoon Chung

Quoted 49 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +48 -0
+
+	host->fifoth_val = MSIZE(0x2) |
+		RX_WMARK(priv->fifo_size / 2 - 1) |
+		TX_WMARK(priv->fifo_size / 2);
+
+	host->fifo_mode = priv->fifo_mode;
+
+	dwmci_setup_cfg(&plat->cfg, host, priv->max_freq, priv->min_freq);
+	host->mmc = &plat->mmc;
+	host->mmc->priv = &priv->host;
+	host->mmc->dev = dev;
+	upriv->mmc = host->mmc;
+
+	nx_dw_mmc_set_pin(host);
+
+	debug("  nx_dw_mmc_set_clk(host, frequency * 4 == %d)\n",
+	      priv->frequency * 4);
+	nx_dw_mmc_set_clk(host, priv->frequency * 4);
+
+	nx_dw_mmc_reset(host->dev_index);
+	nx_dw_mmc_clk_delay(dev);
+
+	return dwmci_probe(dev);
+}
+
+static int nexell_dwmmc_bind(struct udevice *dev)
+{
+	struct nexell_mmc_plat *plat = dev_get_platdata(dev);
+
+	return dwmci_bind(dev, &plat->mmc, &plat->cfg);
+}
+
+static const struct udevice_id nexell_dwmmc_ids[] = {
+	{ .compatible = "nexell,nexell-dwmmc" },
+	{ }
+};
+
+U_BOOT_DRIVER(nexell_dwmmc_drv) = {
+	.name		= "nexell_dwmmc",
+	.id		= UCLASS_MMC,
+	.of_match	= nexell_dwmmc_ids,
+	.ofdata_to_platdata = nexell_dwmmc_ofdata_to_platdata,
+	.ops		= &dm_dwmci_ops,
+	.bind		= nexell_dwmmc_bind,
+	.probe		= nexell_dwmmc_probe,
+	.priv_auto_alloc_size = sizeof(struct nexell_dwmmc_priv),
+	.platdata_auto_alloc_size = sizeof(struct nexell_mmc_plat),
+};
#12 lore raw

RFC PATCH v2 5/13 mmc: add nexell driver

Hi,

Quoted 8 lines · Stefan B.

Hi,

see below my answers to your questions.

Regards
Stefan Bosch

Quoted 8 lines

Hi,

thanks a lot for your reply. As you already guessed I have ported the outdated U-Boot from FriendlyARM, see:
https://protect2.fireeye.com/url?k=00de144b-5d1421fc-00df9f04-0cc47a3003e8-6dd6a1886465f918&q=1&u=https%3A%2F%2Fgithub.com%2Ffriendlyarm%2Fu-boot%2Ftree%2Fnanopi2-v2016.01

The original MMC-driver has been nexell_dw_mmc.c, so I renamed it to nexell_dw_mmc_dm.c after changing to DM.

I will have a closer look at your suggestions and give you feedback ASAP.

I don't know that you had received reviews about other patches.
If you want to apply new chip, then i think you need to implement drivers based on DM.

Quoted 186 lines

Regards
Stefan Bosch

Am 02.04.20 um 13:03 schrieb Jaehoon Chung:

Quoted 8 lines

Hi,

Quoted 2 lines · Stefan Bosch

Changes in relation to FriendlyARM's U-Boot nanopi2-v2016.01:
- mmc: nexell_dw_mmc.c changed to nexell_dw_mmc_dm.c (switched to DM).

It doesn't need to add postfix as _dm.

Ok, I have renamed it to nexell_dw_mmc.c.

Quoted 14 lines
Quoted 14 lines

---

Changes in v2:
- commit "i2c: mmc: add nexell driver (gpio, i2c, mmc, pwm)" splitted ?? into separate commits for gpio, i2c, mmc, pwm.

? drivers/mmc/Kconfig??????????? |?? 6 +
? drivers/mmc/Makefile?????????? |?? 1 +
? drivers/mmc/nexell_dw_mmc_dm.c | 350 +++++++++++++++++++++++++++++++++++++++++

? 3 files changed, 357 insertions(+)
? create mode 100644 drivers/mmc/nexell_dw_mmc_dm.c

Quoted 15 lines
Quoted 5 lines
drivers/mmc/Kconfig +0 -0
index 2f0eedc..bb8e7c0 100644
@@ -253,6 +253,12 @@ config MMC_DW_SNPS
Quoted 7 lines

??????? This selects support for Synopsys DesignWare Memory Card Interface driver ??????? extensions used in various Synopsys ARC devboards.
? +config NEXELL_DWMMC
+??? bool "Nexell SD/MMC controller support"
+??? depends on ARCH_NEXELL
+??? depends on MMC_DW
+??? default y

Not depends on DM_MMC?

You are right, I have inserted "depends on DM_MMC". I missed this when changing to DM.

Quoted 138 lines
Quoted 78 lines

+
? config MMC_MESON_GX
????? bool "Meson GX EMMC controller support"
????? depends on DM_MMC && BLK && ARCH_MESON

drivers/mmc/Makefile +0 -0
index 9c1f8e5..a7b5a7b 100644
@@ -43,6 +43,7 @@ obj-$(CONFIG_SH_MMCIF) += sh_mmcif.o

? obj-$(CONFIG_SH_SDHI) += sh_sdhi.o
? obj-$(CONFIG_STM32_SDMMC2) += stm32_sdmmc2.o
? obj-$(CONFIG_JZ47XX_MMC) += jz_mmc.o
+obj-$(CONFIG_NEXELL_DWMMC) += nexell_dw_mmc_dm.o
? ? # SDHCI
? obj-$(CONFIG_MMC_SDHCI)??????????? += sdhci.o

drivers/mmc/nexell_dw_mmc_dm.c new file +57 -0
new file mode 100644
index 0000000..b06b60d
@@ -0,0 +1,350 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2016 Nexell
+ * Youngbok, Park <[email protected]>
+ *
+ * (C) Copyright 2019 Stefan Bosch <[email protected]>
+ */
+
+#include <common.h>
+#include <clk.h>
+#include <dm.h>
+#include <dt-structs.h>
+#include <dwmmc.h>
+#include <syscon.h>
+#include <asm/gpio.h>
+#include <asm/arch/nx_gpio.h>
+#include <asm/arch/reset.h>
+
+#define DWMCI_CLKSEL??????????? 0x09C
+#define DWMCI_SHIFT_0??????????? 0x0
+#define DWMCI_SHIFT_1??????????? 0x1
+#define DWMCI_SHIFT_2??????????? 0x2
+#define DWMCI_SHIFT_3??????????? 0x3
+#define DWMCI_SET_SAMPLE_CLK(x)??? (x)
+#define DWMCI_SET_DRV_CLK(x)??? ((x) << 16)
+#define DWMCI_SET_DIV_RATIO(x)??? ((x) << 24)
+#define DWMCI_CLKCTRL??????????? 0x114
+#define NX_MMC_CLK_DELAY(x, y, a, b)??? ((((x) & 0xFF) << 0) |\
+??????????????????? (((y) & 0x03) << 16) |\
+??????????????????? (((a) & 0xFF) << 8)? |\
+??????????????????? (((b) & 0x03) << 24))
+
+struct nexell_mmc_plat {
+??? struct mmc_config cfg;
+??? struct mmc mmc;
+};
+
+struct nexell_dwmmc_priv {
+??? struct clk *clk;
+??? struct dwmci_host host;
+??? int fifo_size;
+??? bool fifo_mode;
+??? int frequency;
+??? u32 min_freq;
+??? u32 max_freq;
+??? int d_delay;
+??? int d_shift;
+??? int s_delay;
+??? int s_shift;
+
+};
+
+struct clk *clk_get(const char *id);
+
+static void set_pin_stat(int index, int bit, int value)
+{
+#if !defined(CONFIG_SPL_BUILD)

drivers/mmc/nexell_dw_mmc_dm.c line 67

Quoted 10 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +10 -0
+??? nx_gpio_set_pad_function(index, bit, value);
+#else
+#if defined(CONFIG_ARCH_S5P4418) ||??? \
+??? defined(CONFIG_ARCH_S5P6818)
+
+??? unsigned long base[5] = {
+??????? PHY_BASEADDR_GPIOA, PHY_BASEADDR_GPIOB,
+??????? PHY_BASEADDR_GPIOC, PHY_BASEADDR_GPIOD,
+??????? PHY_BASEADDR_GPIOE,
+??? };

I don't understand why gpio pin is set in mmc driver?
If nexell soc will change the gpio map and function value, does it needs to add other gpio control?

Quoted 33 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +33 -0
+
+??? dw_mmc_set_pin(base[index], bit, value);
+#endif
+#endif
+}
+
+static void nx_dw_mmc_set_pin(struct dwmci_host *host)
+{
+??? debug("? %s(): dev_index == %d", __func__, host->dev_index);
+
+??? switch (host->dev_index) {
+??? case 0:
+??????? set_pin_stat(0, 29, 1);
+??????? set_pin_stat(0, 31, 1);
+??????? set_pin_stat(1, 1, 1);
+??????? set_pin_stat(1, 3, 1);
+??????? set_pin_stat(1, 5, 1);
+??????? set_pin_stat(1, 7, 1);
+??????? break;
+??? case 1:
+??????? set_pin_stat(3, 22, 1);
+??????? set_pin_stat(3, 23, 1);
+??????? set_pin_stat(3, 24, 1);
+??????? set_pin_stat(3, 25, 1);
+??????? set_pin_stat(3, 26, 1);
+??????? set_pin_stat(3, 27, 1);
+??????? break;
+??? case 2:
+??????? set_pin_stat(2, 18, 2);
+??????? set_pin_stat(2, 19, 2);
+??????? set_pin_stat(2, 20, 2);
+??????? set_pin_stat(2, 21, 2);
+??????? set_pin_stat(2, 22, 2);

drivers/mmc/nexell_dw_mmc_dm.c line 110

Quoted 10 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +10 -0
+??????? set_pin_stat(2, 23, 2);
+??????? if (host->buswidth == 8) {
+??????????? set_pin_stat(4, 21, 2);
+??????????? set_pin_stat(4, 22, 2);
+??????????? set_pin_stat(4, 23, 2);
+??????????? set_pin_stat(4, 24, 2);
+??????? }
+??????? break;
+??? default:
+??????? debug(" is invalid!");

Is invalid..then will not work fine?

Quoted 6 lines
Quoted 4 lines

i don't check your patch fully.
Your patch doesn't control gpio with dt?
Well, i don't agree this concept. it need to get opinion how to think about this.

Nexell has not implemented an pinctrl-driver, so the GPIOs are switched to MMC-function here. I have removed the above "default", now I check for a valid dev_index in nexell_dwmmc_ofdata_to_platdata().

Then it needs to implement pinctrl driver.

Quoted 13 lines
Quoted 13 lines

drivers/mmc/nexell_dw_mmc_dm.c line 119

Quoted 10 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +9 -0
+??? }
+??? debug("\n");
+}
+
+static void nx_dw_mmc_clksel(struct dwmci_host *host)
+{
+??? u32 val;
+
+#ifdef CONFIG_BOOST_MMC

What is BOOST_MMC?

Quoted 1 line

This influences what value is written to register offset 0x9C of the MMC-controller. Unfortunatelly, I can not give you more info because this register is indicated as "Reserved" in the S5P4418-datasheet I have access to (Revision 0.10 from October 2014).

I didn't find where BOOST_MMC config is defined.
And it can be used with device-tree property. As i know it's relevant to clk phase and timing.

Quoted 265 lines
Quoted 17 lines
Quoted 4 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +3 -0
+??? val = DWMCI_SET_SAMPLE_CLK(DWMCI_SHIFT_0) |
+??????? DWMCI_SET_DRV_CLK(DWMCI_SHIFT_0) | DWMCI_SET_DIV_RATIO(1);
+#else

drivers/mmc/nexell_dw_mmc_dm.c

Quoted 10 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +10 -0
+??? val = DWMCI_SET_SAMPLE_CLK(DWMCI_SHIFT_0) |
+??????? DWMCI_SET_DRV_CLK(DWMCI_SHIFT_0) | DWMCI_SET_DIV_RATIO(3);
+#endif
+
+??? dwmci_writel(host, DWMCI_CLKSEL, val);
+}
+
+static void nx_dw_mmc_reset(int ch)
+{
+??? int rst_id = RESET_ID_SDMMC0 + ch;

RESET_ID_SDMMC0?

This is defined in arch/arm/include/asm/arch/nexell.h.

Quoted 26 lines
Quoted 26 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +26 -0
+
+??? nx_rstcon_setrst(rst_id, 0);
+??? nx_rstcon_setrst(rst_id, 1);
+}
+
+static void nx_dw_mmc_clk_delay(struct udevice *dev)
+{
+??? unsigned int delay;
+??? struct nexell_dwmmc_priv *priv = dev_get_priv(dev);
+??? struct dwmci_host *host = &priv->host;
+
+??? delay = NX_MMC_CLK_DELAY(priv->d_delay,
+???????????????? priv->d_shift, priv->s_delay, priv->s_shift);
+
+??? writel(delay, (host->ioaddr + DWMCI_CLKCTRL));
+??? debug("%s(): Values set: d_delay==%d, d_shift==%d, s_delay==%d, "
+????????? "s_shift==%d\n", __func__, priv->d_delay, priv->d_shift,
+????????? priv->s_delay, priv->s_shift);
+}
+
+static unsigned int nx_dw_mmc_get_clk(struct dwmci_host *host, uint freq)
+{
+??? struct clk *clk;
+??? struct udevice *dev = host->priv;
+??? struct nexell_dwmmc_priv *priv = dev_get_priv(dev);
+
Quoted 9 lines

drivers/mmc/nexell_dw_mmc_dm.c line 164

Quoted 6 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +6 -0
+??? int index = host->dev_index;
+??? char name[50] = { 0, };
+
+??? clk = priv->clk;
+??? if (!clk) {
+??????? sprintf(name, "%s.%d", DEV_NAME_SDHC, index);

DEV_NAME_SDHC ???

This is also defined in arch/arm/include/asm/arch/nexell.h: "nx-sdhc"

Quoted 128 lines
Quoted 115 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +115 -0
+??????? clk = clk_get((const char *)name);
+??????? if (!clk)
+??????????? return 0;
+??????? priv->clk = clk;
+??? }
+
+??? return clk_get_rate(clk) / 2;
+}
+
+static unsigned long nx_dw_mmc_set_clk(struct dwmci_host *host,
+?????????????????????? unsigned int rate)
+{
+??? struct clk *clk;
+??? char name[50] = { 0, };
+??? struct udevice *dev = host->priv;
+??? struct nexell_dwmmc_priv *priv = dev_get_priv(dev);
+
+??? int index = host->dev_index;
+
+??? clk = priv->clk;
+??? if (!clk) {
+??????? sprintf(name, "%s.%d", DEV_NAME_SDHC, index);
+??????? clk = clk_get((const char *)name);
+??????? if (!clk)
+??????????? return 0;
+??????? priv->clk = clk;
+??? }
+
+??? clk_disable(clk);
+??? rate = clk_set_rate(clk, rate);
+??? clk_enable(clk);
+
+??? return rate;
+}
+
+static int nexell_dwmmc_ofdata_to_platdata(struct udevice *dev)
+{
+??? /* if (dev): *priv = dev->priv, else: *priv = NULL */
+??? struct nexell_dwmmc_priv *priv = dev_get_priv(dev);
+??? struct dwmci_host *host = &priv->host;
+??? int val = -1;
+
+??? debug("%s()\n", __func__);
+
+??? host->name = dev->name;
+??? host->ioaddr = dev_read_addr_ptr(dev);
+
+??? val = dev_read_u32_default(dev, "nexell,bus-width", -1);
+??? if (val < 0) {
+??????? debug("? 'nexell,bus-width' missing/invalid!\n");
+??????? return -EINVAL;
+??? }
+??? host->buswidth = val;
+??? host->get_mmc_clk = nx_dw_mmc_get_clk;
+??? host->clksel = nx_dw_mmc_clksel;
+??? host->priv = dev;
+
+??? val = dev_read_u32_default(dev, "index", -1);
+??? if (val < 0) {
+??????? debug("? 'index' missing/invalid!\n");
+??????? return -EINVAL;
+??? }
+??? host->dev_index = val;
+
+??? val = dev_read_u32_default(dev, "fifo-size", 0x20);
+??? if (val <= 0) {
+??????? debug("? 'fifo-size' missing/invalid!\n");
+??????? return -EINVAL;
+??? }
+??? priv->fifo_size = val;
+
+??? priv->fifo_mode = dev_read_bool(dev, "fifo-mode");
+
+??? val = dev_read_u32_default(dev, "frequency", -1);
+??? if (val < 0) {
+??????? debug("? 'frequency' missing/invalid!\n");
+??????? return -EINVAL;
+??? }
+??? priv->frequency = val;
+
+??? val = dev_read_u32_default(dev, "max-frequency", -1);
+??? if (val < 0) {
+??????? debug("? 'max-frequency' missing/invalid!\n");
+??????? return -EINVAL;
+??? }
+??? priv->max_freq = val;
+??? priv->min_freq = 400000;? /* 400 kHz */
+
+??? val = dev_read_u32_default(dev, "nexell,drive_dly", -1);
+??? if (val < 0) {
+??????? debug("? 'nexell,drive_dly' missing/invalid!\n");
+??????? return -EINVAL;
+??? }
+??? priv->d_delay = val;
+
+??? val = dev_read_u32_default(dev, "nexell,drive_shift", -1);
+??? if (val < 0) {
+??????? debug("? 'nexell,drive_shift' missing/invalid!\n");
+??????? return -EINVAL;
+??? }
+??? priv->d_shift = val;
+
+??? val = dev_read_u32_default(dev, "nexell,sample_dly", -1);
+??? if (val < 0) {
+??????? debug("? 'nexell,sample_dly' missing/invalid!\n");
+??????? return -EINVAL;
+??? }
+??? priv->s_delay = val;
+
+??? val = dev_read_u32_default(dev, "nexell,sample_shift", -1);
+??? if (val < 0) {
+??????? debug("? 'nexell,sample_shift' missing/invalid!\n");
+??????? return -EINVAL;
+??? }
+??? priv->s_shift = val;

drivers/mmc/nexell_dw_mmc_dm.c line 289

Quoted 10 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +10 -0
+
+??? debug("? index==%d, name==%s, ioaddr==0x%08x, buswidth==%d, "
+????????? "fifo_size==%d, fifo_mode==%d, frequency==%d\n",
+????????? host->dev_index, host->name, (u32)host->ioaddr,
+????????? host->buswidth, priv->fifo_size, priv->fifo_mode,
+????????? priv->frequency);
+??? debug("? min_freq==%d, max_freq==%d, delay: "
+????????? "0x%02x:0x%02x:0x%02x:0x%02x\n",
+????????? priv->min_freq, priv->max_freq, priv->d_delay,
+????????? priv->d_shift, priv->s_delay, priv->s_shift);

entirely not readable. not need to assign again with val.

Quoted 3 lines

priv->s_deley = dev_read_u32_default();

I have reworked nexell_dwmmc_ofdata_to_platdata(), i.e. valid default values are used now (where possible) and the appropriate if-blocks have been removed.

Quoted 7 lines
Quoted 7 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +7 -0
+
+??? return 0;
+}
+
+static int nexell_dwmmc_probe(struct udevice *dev)
+{
+??? struct nexell_mmc_plat *plat = dev_get_platdata(dev);
Quoted 9 lines

drivers/mmc/nexell_dw_mmc_dm.c line 302

Quoted 6 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +6 -0
+??? struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
+??? struct nexell_dwmmc_priv *priv = dev_get_priv(dev);
+??? struct dwmci_host *host = &priv->host;
+??? struct udevice *pwr_dev __maybe_unused;
+
+??? debug("%s():\n", __func__);

Don't add unnecessary debug code. it's meaningless even if it's enabled.

Ok, I have removed this debug code.

Quoted 56 lines

Well, i didn't check other patches..but i think that your patches seems to based on older u-boot version.

Best Regards,
Jaehoon Chung

Quoted 49 lines
drivers/mmc/nexell_dw_mmc_dm.c new file +48 -0
+
+??? host->fifoth_val = MSIZE(0x2) |
+??????? RX_WMARK(priv->fifo_size / 2 - 1) |
+??????? TX_WMARK(priv->fifo_size / 2);
+
+??? host->fifo_mode = priv->fifo_mode;
+
+??? dwmci_setup_cfg(&plat->cfg, host, priv->max_freq, priv->min_freq);
+??? host->mmc = &plat->mmc;
+??? host->mmc->priv = &priv->host;
+??? host->mmc->dev = dev;
+??? upriv->mmc = host->mmc;
+
+??? nx_dw_mmc_set_pin(host);
+
+??? debug("? nx_dw_mmc_set_clk(host, frequency * 4 == %d)\n",
+????????? priv->frequency * 4);
+??? nx_dw_mmc_set_clk(host, priv->frequency * 4);
+
+??? nx_dw_mmc_reset(host->dev_index);
+??? nx_dw_mmc_clk_delay(dev);
+
+??? return dwmci_probe(dev);
+}
+
+static int nexell_dwmmc_bind(struct udevice *dev)
+{
+??? struct nexell_mmc_plat *plat = dev_get_platdata(dev);
+
+??? return dwmci_bind(dev, &plat->mmc, &plat->cfg);
+}
+
+static const struct udevice_id nexell_dwmmc_ids[] = {
+??? { .compatible = "nexell,nexell-dwmmc" },
+??? { }
+};
+
+U_BOOT_DRIVER(nexell_dwmmc_drv) = {
+??? .name??????? = "nexell_dwmmc",
+??? .id??????? = UCLASS_MMC,
+??? .of_match??? = nexell_dwmmc_ids,
+??? .ofdata_to_platdata = nexell_dwmmc_ofdata_to_platdata,
+??? .ops??????? = &dm_dwmci_ops,
+??? .bind??????? = nexell_dwmmc_bind,
+??? .probe??????? = nexell_dwmmc_probe,
+??? .priv_auto_alloc_size = sizeof(struct nexell_dwmmc_priv),
+??? .platdata_auto_alloc_size = sizeof(struct nexell_mmc_plat),
+};
#13 lore raw

RFC PATCH v2 6/13 pwm: add driver for nexell

In reply to Stefan Bosch

Changes in relation to FriendlyARM's U-Boot nanopi2-v2016.01:
- Since drivers/pwm/pwm-nexell.c is an adapted version of s5p-common/pwm.c an appropriately changed version of s5p-common/pwm.c is used instead. Therefore arch/arm/mach-s5pc1xx/include/mach/pwm.h copied to arch/arm/mach-nexell/include/mach and s5p-common/Makefile changed appropriately.

---

Changes in v2:
- commit "i2c: mmc: add nexell driver (gpio, i2c, mmc, pwm)" splitted into separate commits for gpio, i2c, mmc, pwm.
- Since drivers/pwm/pwm-nexell.c is an adapted version of s5p-common/pwm.c an appropriately changed version of s5p-common/pwm.c is used now. Therefore arch/arm/mach-s5pc1xx/include/mach/pwm.h copied to arch/arm/mach-nexell/include/mach and s5p-common/Makefile changed appropriately.

 arch/arm/cpu/armv7/s5p-common/Makefile  |  4 +++
 arch/arm/cpu/armv7/s5p-common/pwm.c     | 56 +++++++++++++++++++++++++++++++++
 arch/arm/mach-nexell/include/mach/pwm.h | 54 +++++++++++++++++++++++++++++++
 3 files changed, 114 insertions(+)
 create mode 100644 arch/arm/mach-nexell/include/mach/pwm.h
arch/arm/cpu/armv7/s5p-common/Makefile +4 -0
index 12cf804..3d4649b 100644
@@ -3,9 +3,13 @@
 # Copyright (C) 2009 Samsung Electronics
 # Minkyu Kang <[email protected]>
 
+ifdef CONFIG_ARCH_NEXELL
+obj-$(CONFIG_PWM_NX)	+= pwm.o
+else
 obj-y		+= cpu_info.o
 ifndef CONFIG_SPL_BUILD
 obj-y		+= timer.o
 obj-y		+= sromc.o
 obj-$(CONFIG_PWM)	+= pwm.o
 endif
+endif
arch/arm/cpu/armv7/s5p-common/pwm.c +56 -0

112 lines not on this page · raw message

arch/arm/mach-nexell/include/mach/pwm.h new file +54 -0

54 lines not on this page · raw message

Signature · 1 line
1.9.1
#14 lore raw

RFC PATCH v2 7/13 video: add nexell video driver (soc: displaytop)

In reply to Stefan Bosch

Low level functions for DisplayTop (Display Topology).

---

Changes in v2: None

 drivers/video/nexell/soc/s5pxx18_soc_disptop.c     | 185 ++++++++++
 drivers/video/nexell/soc/s5pxx18_soc_disptop.h     | 385 +++++++++++++++++++++
 drivers/video/nexell/soc/s5pxx18_soc_disptop_clk.c | 309 +++++++++++++++++
 drivers/video/nexell/soc/s5pxx18_soc_disptop_clk.h |  59 ++++
 drivers/video/nexell/soc/s5pxx18_soc_disptype.h    |  23 ++
 5 files changed, 961 insertions(+)
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_disptop.c
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_disptop.h
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_disptop_clk.c
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_disptop_clk.h
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_disptype.h
drivers/video/nexell/soc/s5pxx18_soc_disptop.c new file +185 -0
new file mode 100644
index 0000000..626e53a
@@ -0,0 +1,185 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2016  Nexell Co., Ltd.
+ *
+ * Author: junghyun, kim <[email protected]>
+ */
+
+#include <linux/types.h>
+#include <linux/io.h>
+
+#include "s5pxx18_soc_disptop.h"
+
+static struct {
+	struct nx_disp_top_register_set *pregister;
+} __g_module_variables = { NULL, };
+
+int nx_disp_top_initialize(void)
+{
+	static int binit;
+	u32 i;
+
+	if (binit == 0) {
+		for (i = 0; i < NUMBER_OF_DISPTOP_MODULE; i++)
+			__g_module_variables.pregister = NULL;
+		binit = 1;
+	}
+	return 1;
+}
+
+u32 nx_disp_top_get_number_of_module(void)
+{
+	return NUMBER_OF_DISPTOP_MODULE;
+}
+
+u32 nx_disp_top_get_physical_address(void)
+{
+	static const u32 physical_addr[] = PHY_BASEADDR_DISPTOP_LIST;
+
+	return (u32)(physical_addr[0] + PHY_BASEADDR_DISPLAYTOP_MODULE_OFFSET);
+}
+
+u32 nx_disp_top_get_size_of_register_set(void)
+{
+	return sizeof(struct nx_disp_top_register_set);
+}
+
+void nx_disp_top_set_base_address(void *base_address)
+{
+	__g_module_variables.pregister =
+	    (struct nx_disp_top_register_set *)base_address;
+}
+
+void *nx_disp_top_get_base_address(void)
+{
+	return (void *)__g_module_variables.pregister;
+}
+
+void nx_disp_top_set_resconvmux(int benb, u32 sel)
+{
+	register struct nx_disp_top_register_set *pregister;
+	u32 regvalue;
+
+	pregister = __g_module_variables.pregister;
+	regvalue = (benb << 31) | (sel << 0);
+	writel((u32)regvalue, &pregister->resconv_mux_ctrl);
+}
+
+void nx_disp_top_set_hdmimux(int benb, u32 sel)
+{
+	register struct nx_disp_top_register_set *pregister;
+	u32 regvalue;
+
+	pregister = __g_module_variables.pregister;
+	regvalue = (benb << 31) | (sel << 0);
+	writel((u32)regvalue, &pregister->interconv_mux_ctrl);
+}
+
+void nx_disp_top_set_mipimux(int benb, u32 sel)
+{
+	register struct nx_disp_top_register_set *pregister;
+	u32 regvalue;
+
+	pregister = __g_module_variables.pregister;
+	regvalue = (benb << 31) | (sel << 0);
+	writel((u32)regvalue, &pregister->mipi_mux_ctrl);
+}
+
+void nx_disp_top_set_lvdsmux(int benb, u32 sel)
+{
+	register struct nx_disp_top_register_set *pregister;
+	u32 regvalue;
+
+	pregister = __g_module_variables.pregister;
+	regvalue = (benb << 31) | (sel << 0);
+	writel((u32)regvalue, &pregister->lvds_mux_ctrl);
+}
+
+void nx_disp_top_set_primary_mux(u32 sel)
+{
+	register struct nx_disp_top_register_set *pregister;
+
+	pregister = __g_module_variables.pregister;
+	writel((u32)sel, &pregister->tftmpu_mux);
+}
+
+void nx_disp_top_hdmi_set_vsync_start(u32 sel)
+{
+	register struct nx_disp_top_register_set *pregister;
+
+	pregister = __g_module_variables.pregister;
+	writel((u32)sel, &pregister->hdmisyncctrl0);
+}
+
+void nx_disp_top_hdmi_set_vsync_hsstart_end(u32 start, u32 end)
+{
+	register struct nx_disp_top_register_set *pregister;
+
+	pregister = __g_module_variables.pregister;
+	writel((u32)(end << 16) | (start << 0), &pregister->hdmisyncctrl3);
+}
+
+void nx_disp_top_hdmi_set_hactive_start(u32 sel)
+{
+	register struct nx_disp_top_register_set *pregister;
+
+	pregister = __g_module_variables.pregister;
+	writel((u32)sel, &pregister->hdmisyncctrl1);
+}
+
+void nx_disp_top_hdmi_set_hactive_end(u32 sel)
+{
+	register struct nx_disp_top_register_set *pregister;
+
+	pregister = __g_module_variables.pregister;
+	writel((u32)sel, &pregister->hdmisyncctrl2);
+}
+
+void nx_disp_top_set_hdmifield(u32 enable, u32 init_val, u32 vsynctoggle,
+			       u32 hsynctoggle, u32 vsyncclr, u32 hsyncclr,
+			       u32 field_use, u32 muxsel)
+{
+	register struct nx_disp_top_register_set *pregister;
+	u32 regvalue;
+
+	pregister = __g_module_variables.pregister;
+	regvalue = ((enable & 0x01) << 0) | ((init_val & 0x01) << 1) |
+		   ((vsynctoggle & 0x3fff) << 2) |
+		   ((hsynctoggle & 0x3fff) << 17);
+	writel(regvalue, &pregister->hdmifieldctrl);
+	regvalue = ((field_use & 0x01) << 31) | ((muxsel & 0x01) << 30) |
+		   ((hsyncclr) << 15) | ((vsyncclr) << 0);
+	writel(regvalue, &pregister->greg0);
+}
+
+void nx_disp_top_set_padclock(u32 mux_index, u32 padclk_cfg)
+{
+	register struct nx_disp_top_register_set *pregister;
+	u32 regvalue;
+
+	pregister = __g_module_variables.pregister;
+	regvalue = readl(&pregister->greg1);
+	if (padmux_secondary_mlc == mux_index) {
+		regvalue = regvalue & (~(0x7 << 3));
+		regvalue = regvalue | (padclk_cfg << 3);
+	} else if (padmux_resolution_conv == mux_index) {
+		regvalue = regvalue & (~(0x7 << 6));
+		regvalue = regvalue | (padclk_cfg << 6);
+	} else {
+		regvalue = regvalue & (~(0x7 << 0));
+		regvalue = regvalue | (padclk_cfg << 0);
+	}
+	writel(regvalue, &pregister->greg1);
+}
+
+void nx_disp_top_set_lcdif_enb(int enb)
+{
+	register struct nx_disp_top_register_set *pregister;
+	u32 regvalue;
+
+	pregister = __g_module_variables.pregister;
+	regvalue = readl(&pregister->greg1);
+	regvalue = regvalue & (~(0x1 << 9));
+	regvalue = regvalue | ((enb & 0x1) << 9);
+	writel(regvalue, &pregister->greg1);
+}
drivers/video/nexell/soc/s5pxx18_soc_disptop.h new file +385 -0

385 lines not on this page · raw message

drivers/video/nexell/soc/s5pxx18_soc_disptop_clk.c new file +309 -0

309 lines not on this page · raw message

drivers/video/nexell/soc/s5pxx18_soc_disptop_clk.h new file +59 -0

59 lines not on this page · raw message

drivers/video/nexell/soc/s5pxx18_soc_disptype.h new file +23 -0
new file mode 100644
index 0000000..b5df7a7
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0+
+ *
+ * Copyright (C) 2016  Nexell Co., Ltd.
+ *
+ * Author: junghyun, kim <[email protected]>
+ */
+
+#ifndef _S5PXX18_SOC_DISP_TYPE_H_
+#define _S5PXX18_SOC_DISP_TYPE_H_
+
+/* clock control types */
+enum nx_pclkmode {
+	nx_pclkmode_dynamic = 0UL,
+	nx_pclkmode_always	= 1UL
+};
+
+enum nx_bclkmode {
+	nx_bclkmode_disable	= 0UL,
+	nx_bclkmode_dynamic	= 2UL,
+	nx_bclkmode_always	= 3UL
+};
+
+#endif
Signature · 1 line
1.9.1
#15 lore raw

RFC PATCH v2 8/13 video: add nexell video driver (soc: mlc, mipi)

In reply to Stefan Bosch

Low level functions for MLC (Multi Layer Control) and MIPI (Mobile Industry Processor Interface).

---

Changes in v2: None

 drivers/video/nexell/soc/s5pxx18_soc_mipi.c |  580 +++++++++
 drivers/video/nexell/soc/s5pxx18_soc_mipi.h |  291 +++++
 drivers/video/nexell/soc/s5pxx18_soc_mlc.c  | 1861 +++++++++++++++++++++++++++
 drivers/video/nexell/soc/s5pxx18_soc_mlc.h  |  429 ++++++
 4 files changed, 3161 insertions(+)
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_mipi.c
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_mipi.h
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_mlc.c
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_mlc.h
drivers/video/nexell/soc/s5pxx18_soc_mipi.c new file +580 -0
new file mode 100644
index 0000000..1000ddb
@@ -0,0 +1,580 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2016  Nexell Co., Ltd.
+ *
+ * Author: junghyun, kim <[email protected]>
+ */
+
+#include <linux/types.h>
+#include <linux/io.h>
+
+#include "s5pxx18_soc_disptop.h"
+#include "s5pxx18_soc_mipi.h"
+
+static struct nx_mipi_register_set *__g_pregister[NUMBER_OF_MIPI_MODULE];
+
+int nx_mipi_smoke_test(u32 module_index)
+{
+	register struct nx_mipi_register_set *pregister;
+
+	pregister = __g_pregister[module_index];
+
+	if (pregister->csis_config_ch0 != 0x000000FC)
+		return false;
+
+	if (pregister->dsim_intmsk != 0xB337FFFF)
+		return false;
+
+	writel(0xDEADC0DE, &pregister->csis_dphyctrl);
+	writel(0xFFFFFFFF, &pregister->csis_ctrl2);
+	writel(0xDEADC0DE, &pregister->dsim_msync);
+
+	if (pregister->csis_dphyctrl != 0xDE80001E)
+		return false;
+
+	if ((pregister->csis_ctrl2 & (~1)) != 0xEEE00010)
+		return false;
+
+	if (pregister->dsim_msync != 0xDE80C0DE)
+		return false;
+
+	return true;
+}
+
+void nx_mipi_set_base_address(u32 module_index, void *base_address)
+{
+	__g_pregister[module_index] =
+	    (struct nx_mipi_register_set *)base_address;
+}
+
+void *nx_mipi_get_base_address(u32 module_index)
+{
+	return (void *)__g_pregister[module_index];
+}
+
+u32 nx_mipi_get_physical_address(u32 module_index)
+{
+	const u32 physical_addr[] = PHY_BASEADDR_MIPI_LIST;
+
+	return physical_addr[module_index];
+}
+
+#define __nx_mipi_valid_dsi_intmask__	\
+	(~((1 << 26) | (1 << 23) | (1 << 22) | (1 << 19)))
+
+void nx_mipi_set_interrupt_enable(u32 module_index, u32 int_num, int enable)
+{
+	register struct nx_mipi_register_set *pregister;
+	register u32 regvalue;
+
+	pregister = __g_pregister[module_index];
+	if (int_num < 32) {
+		regvalue = pregister->csis_intmsk;
+		regvalue &= ~(1ul << int_num);
+		regvalue |= (u32)enable << int_num;
+		writel(regvalue, &pregister->csis_intmsk);
+	} else {
+		regvalue = pregister->dsim_intmsk;
+		regvalue &= ~(1ul << (int_num - 32));
+		regvalue |= (u32)enable << (int_num - 32);
+		writel(regvalue, &pregister->dsim_intmsk);
+	}
+}
+
+int nx_mipi_get_interrupt_enable(u32 module_index, u32 int_num)
+{
+	if (int_num < 32)
+		return (int)((__g_pregister[module_index]->csis_intmsk >>
+			      int_num) & 0x01);
+	else
+		return (int)((__g_pregister[module_index]->dsim_intmsk >>
+			      (int_num - 32)) & 0x01);
+}
+
+int nx_mipi_get_interrupt_pending(u32 module_index, u32 int_num)
+{
+	register struct nx_mipi_register_set *pregister;
+	register u32 regvalue;
+	int ret;
+
+	pregister = __g_pregister[module_index];
+	if (int_num < 32) {
+		regvalue = pregister->csis_intmsk;
+		regvalue &= pregister->csis_intsrc;
+		ret = (int)((regvalue >> int_num) & 0x01);
+	} else {
+		regvalue = pregister->dsim_intmsk;
+		regvalue &= pregister->dsim_intsrc;
+		ret = (int)((regvalue >> (int_num - 32)) & 0x01);
+	}
+
+	return ret;
+}
+
+void nx_mipi_clear_interrupt_pending(u32 module_index, u32 int_num)
+{
+	register struct nx_mipi_register_set *pregister;
+
+	pregister = __g_pregister[module_index];
+	if (int_num < 32)
+		writel(1ul << int_num, &pregister->csis_intsrc);
+	else
+		writel(1ul << (int_num - 32), &pregister->dsim_intsrc);
+}
+
+void nx_mipi_set_interrupt_enable_all(u32 module_index, int enable)
+{
+	register struct nx_mipi_register_set *pregister;
+
+	pregister = __g_pregister[module_index];
+	if (enable)
+		writel(__nx_mipi_valid_dsi_intmask__, &pregister->dsim_intmsk);
+	else
+		writel(0, &pregister->dsim_intmsk);
+}
+
+int nx_mipi_get_interrupt_enable_all(u32 module_index)
+{
+	if (__g_pregister[module_index]->csis_intmsk)
+		return true;
+
+	if (__g_pregister[module_index]->dsim_intmsk)
+		return true;
+
+	return false;
+}
+
+int nx_mipi_get_interrupt_pending_all(u32 module_index)
+{
+	register struct nx_mipi_register_set *pregister;
+	register u32 regvalue;
+
+	pregister = __g_pregister[module_index];
+	regvalue = pregister->csis_intmsk;
+	regvalue &= pregister->csis_intsrc;
+
+	if (regvalue)
+		return true;
+
+	regvalue = pregister->dsim_intmsk;
+	regvalue &= pregister->dsim_intsrc;
+
+	if (regvalue)
+		return true;
+
+	return false;
+}
+
+void nx_mipi_clear_interrupt_pending_all(u32 module_index)
+{
+	register struct nx_mipi_register_set *pregister;
+
+	pregister = __g_pregister[module_index];
+	writel(__nx_mipi_valid_dsi_intmask__, &pregister->dsim_intsrc);
+}
+
+int32_t nx_mipi_get_interrupt_pending_number(u32 module_index)
+{
+	register struct nx_mipi_register_set *pregister;
+	register u32 regvalue;
+	int i;
+
+	pregister = __g_pregister[module_index];
+	regvalue = pregister->csis_intmsk;
+	regvalue &= pregister->csis_intsrc;
+	if (regvalue != 0) {
+		for (i = 0; i < 32; i++) {
+			if (regvalue & 1ul)
+				return i;
+			regvalue >>= 1;
+		}
+	}
+
+	regvalue = pregister->dsim_intmsk;
+	regvalue &= pregister->dsim_intsrc;
+	if (regvalue != 0) {
+		for (i = 0; i < 32; i++) {
+			if (regvalue & 1ul)
+				return i + 32;
+			regvalue >>= 1;
+		}
+	}
+	return -1;
+}
+
+#define writereg(regname, mask, value) \
+	regvalue = pregister->(regname);	\
+	regvalue = (regvalue & (~(mask))) | (value); \
+	writel(regvalue, &pregister->(regname))
+
+void nx_mipi_dsi_get_status(u32 module_index, u32 *pulps, u32 *pstop,
+			    u32 *pispllstable, u32 *pisinreset,
+			    u32 *pisbackward, u32 *pishsclockready)
+{
+	register struct nx_mipi_register_set *pregister;
+	register u32 regvalue;
+
+	pregister = __g_pregister[module_index];
+	regvalue = pregister->dsim_status;
+	if (pulps) {
+		*pulps = 0;
+		if (regvalue & (1 << 4))
+			*pulps |= (1 << 0);
+		if (regvalue & (1 << 5))
+			*pulps |= (1 << 1);
+		if (regvalue & (1 << 6))
+			*pulps |= (1 << 2);
+		if (regvalue & (1 << 7))
+			*pulps |= (1 << 3);
+		if (regvalue & (1 << 9))
+			*pulps |= (1 << 4);
+	}
+
+	if (pstop) {
+		*pstop = 0;
+		if (regvalue & (1 << 0))
+			*pstop |= (1 << 0);
+		if (regvalue & (1 << 1))
+			*pstop |= (1 << 1);
+		if (regvalue & (1 << 2))
+			*pstop |= (1 << 2);
+		if (regvalue & (1 << 3))
+			*pstop |= (1 << 3);
+		if (regvalue & (1 << 8))
+			*pstop |= (1 << 4);
+	}
+
+	if (pispllstable)
+		*pispllstable = (regvalue >> 31) & 1;
+
+	if (pisinreset)
+		*pisinreset = ((regvalue >> 20) & 1) ? 0 : 1;
+
+	if (pisbackward)
+		*pisbackward = (regvalue >> 16) & 1;
+
+	if (pishsclockready)
+		*pishsclockready = (regvalue >> 10) & 1;
+}
+
+void nx_mipi_dsi_software_reset(u32 module_index)
+{
+	register struct nx_mipi_register_set *pregister;
+
+	pregister = __g_pregister[module_index];
+
+	writel(0x00010001, &pregister->dsim_swrst);
+
+	while (0 != (readl(&pregister->dsim_status) & (1 << 20)))
+		;
+
+	writel(0x00000000, &pregister->dsim_swrst);
+}
+
+void nx_mipi_dsi_set_clock(u32 module_index, int enable_txhsclock,
+			   int use_external_clock, int enable_byte_clock,
+			   int enable_escclock_clock_lane,
+			   int enable_escclock_data_lane0,
+			   int enable_escclock_data_lane1,
+			   int enable_escclock_data_lane2,
+			   int enable_escclock_data_lane3,
+			   int enable_escprescaler, u32 escprescalervalue)
+{
+	register struct nx_mipi_register_set *pregister;
+	register u32 regvalue;
+
+	pregister = __g_pregister[module_index];
+	regvalue = 0;
+	regvalue |= (enable_txhsclock << 31);
+	regvalue |= (use_external_clock << 27);
+	regvalue |= (enable_byte_clock << 24);
+	regvalue |= (enable_escclock_clock_lane << 19);
+	regvalue |= (enable_escclock_data_lane0 << 20);
+	regvalue |= (enable_escclock_data_lane1 << 21);
+	regvalue |= (enable_escclock_data_lane2 << 22);
+	regvalue |= (enable_escclock_data_lane3 << 23);
+	regvalue |= (enable_escprescaler << 28);
+	regvalue |= escprescalervalue;
+
+	writel(regvalue, &pregister->dsim_clkctrl);
+}
+
+void nx_mipi_dsi_set_timeout(u32 module_index, u32 bta_tout, u32 lpdrtout)
+{
+	register struct nx_mipi_register_set *pregister;
+	register u32 regvalue;
+
+	pregister = __g_pregister[module_index];
+	regvalue = 0;
+	regvalue |= (bta_tout << 16);
+	regvalue |= (lpdrtout << 0);
+
+	writel(regvalue, &pregister->dsim_timeout);
+}
+
+void nx_mipi_dsi_set_config_video_mode(u32 module_index,
+				       int enable_auto_flush_main_display_fifo,
+				       int enable_auto_vertical_count,
+				       int enable_burst,
+				       enum nx_mipi_dsi_syncmode sync_mode,
+				       int enable_eo_tpacket,
+				       int enable_hsync_end_packet,
+				       int enable_hfp, int enable_hbp,
+				       int enable_hsa,
+				       u32 number_of_virtual_channel,
+				       enum nx_mipi_dsi_format format,
+				       u32 number_of_words_in_hfp,
+				       u32 number_of_words_in_hbp,
+				       u32 number_of_words_in_hsync,
+				       u32 number_of_lines_in_vfp,
+				       u32 number_of_lines_in_vbp,
+				       u32 number_of_lines_in_vsync,
+				       u32 number_of_lines_in_command_allow)
+{
+	register struct nx_mipi_register_set *pregister;
+	register u32 regvalue;
+	u32 newvalue;
+
+	pregister = __g_pregister[module_index];
+	newvalue = (1 << 25);
+	newvalue |= ((1 - enable_auto_flush_main_display_fifo) << 29);
+	newvalue |= (enable_auto_vertical_count << 24);
+	newvalue |= (enable_burst << 26);
+	newvalue |= (sync_mode << 27);
+	newvalue |= ((1 - enable_eo_tpacket) << 28);
+	newvalue |= (enable_hsync_end_packet << 23);
+	newvalue |= ((1 - enable_hfp) << 22);
+	newvalue |= ((1 - enable_hbp) << 21);
+	newvalue |= ((1 - enable_hsa) << 20);
+	newvalue |= (number_of_virtual_channel << 18);
+	newvalue |= (format << 12);
+
+	writereg(dsim_config, 0xFFFFFF00, newvalue);
+
+	newvalue = (number_of_lines_in_command_allow << 28);
+	newvalue |= (number_of_lines_in_vfp << 16);
+	newvalue |= (number_of_lines_in_vbp << 0);
+
+	writel(newvalue, &pregister->dsim_mvporch);
+
+	newvalue = (number_of_words_in_hfp << 16);
+	newvalue |= (number_of_words_in_hbp << 0);
+
+	writel(newvalue, &pregister->dsim_mhporch);
+
+	newvalue = (number_of_words_in_hsync << 0);
+	newvalue |= (number_of_lines_in_vsync << 22);
+
+	writel(newvalue, &pregister->dsim_msync);
+}
+
+void nx_mipi_dsi_set_config_command_mode(u32 module_index,
+					 int
+					 enable_auto_flush_main_display_fifo,
+					 int enable_eo_tpacket,
+					 u32 number_of_virtual_channel,
+					 enum nx_mipi_dsi_format format)
+{
+	register struct nx_mipi_register_set *pregister;
+	register u32 regvalue;
+	u32 newvalue;
+
+	pregister = __g_pregister[module_index];
+	newvalue = (0 << 25);
+	newvalue |= (enable_auto_flush_main_display_fifo << 29);
+	newvalue |= (enable_eo_tpacket << 28);
+	newvalue |= (number_of_virtual_channel << 18);
+	newvalue |= (format << 12);
+	writereg(dsim_config, 0xFFFFFF00, newvalue);
+}
+
+void nx_mipi_dsi_set_escape_mode(u32 module_index, u32 stop_state_count,
+				 int force_stop_state, int force_bta,
+				 enum nx_mipi_dsi_lpmode cmdin_lp,
+				 enum nx_mipi_dsi_lpmode txinlp)
+{
+	register struct nx_mipi_register_set *pregister;
+	register u32 regvalue;
+	u32 newvalue;
+
+	pregister = __g_pregister[module_index];
+	newvalue = (stop_state_count << 21);
+	newvalue |= (force_stop_state << 20);
+	newvalue |= (force_bta << 16);
+	newvalue |= (cmdin_lp << 7);
+	newvalue |= (txinlp << 6);
+	writereg(dsim_escmode, 0xFFFFFFC0, newvalue);
+}
+
+void nx_mipi_dsi_set_escape_lp(u32 module_index,
+			       enum nx_mipi_dsi_lpmode cmdin_lp,
+			       enum nx_mipi_dsi_lpmode txinlp)
+{
+	register struct nx_mipi_register_set *pregister;
+	register u32 regvalue;
+	u32 newvalue = 0;
+
+	pregister = __g_pregister[module_index];
+	newvalue |= (cmdin_lp << 7);
+	newvalue |= (txinlp << 6);
+	writereg(dsim_escmode, 0xC0, newvalue);
+}
+
+void nx_mipi_dsi_remote_reset_trigger(u32 module_index)
+{
+	register struct nx_mipi_register_set *pregister;
+	register u32 regvalue;
+	u32 newvalue;
+
+	pregister = __g_pregister[module_index];
+	newvalue = (1 << 4);
+	writereg(dsim_escmode, (1 << 4), newvalue);
+
+	while (readl(&pregister->dsim_escmode) & (1 << 4))
+		;
+}
+
+void nx_mipi_dsi_set_ulps(u32 module_index, int ulpsclocklane, int ulpsdatalane)
+{
+	register struct nx_mipi_register_set *pregister;
+	register u32 regvalue;
+
+	pregister = __g_pregister[module_index];
+	regvalue = pregister->dsim_escmode;
+
+	if (ulpsclocklane) {
+		regvalue &= ~(1 << 0);
+		regvalue |= (1 << 1);
+	} else {
+		regvalue |= (1 << 0);
+	}
+
+	if (ulpsdatalane) {
+		regvalue &= ~(1 << 2);
+		regvalue |= (1 << 3);
+	} else {
+		regvalue |= (1 << 2);
+	}
+
+	writel(regvalue, &pregister->dsim_escmode);
+
+	if (ulpsclocklane)
+		while ((1 << 9) ==
+		       (readl(&pregister->dsim_status) & (1 << 9)))
+			;
+	else
+		while (0 != (readl(&pregister->dsim_status) & (1 << 9)))
+			;
+
+	if (ulpsdatalane)
+		while ((15 << 4) ==
+		       (readl(&pregister->dsim_status) & (15 << 4)))
+			;
+	else
+		while (0 != (readl(&pregister->dsim_status) & (15 << 4)))
+			;
+
+	if (!ulpsclocklane)
+		regvalue &= (3 << 0);
+
+	if (!ulpsdatalane)
+		regvalue |= (3 << 2);
+
+	writel(regvalue, &pregister->dsim_escmode);
+}
+
+void nx_mipi_dsi_set_size(u32 module_index, u32 width, u32 height)
+{
+	register struct nx_mipi_register_set *pregister;
+	register u32 regvalue;
+	u32 newvalue;
+
+	pregister = __g_pregister[module_index];
+	newvalue = (height << 16);
+	newvalue |= (width << 0);
+	writereg(dsim_mdresol, 0x0FFFFFFF, newvalue);
+}
+
+void nx_mipi_dsi_set_enable(u32 module_index, int enable)
+{
+	register struct nx_mipi_register_set *pregister;
+	register u32 regvalue;
+
+	pregister = __g_pregister[module_index];
+	writereg(dsim_mdresol, (1 << 31), (enable << 31));
+}
+
+void nx_mipi_dsi_set_phy(u32 module_index, u32 number_of_data_lanes,
+			 int enable_clock_lane, int enable_data_lane0,
+			 int enable_data_lane1, int enable_data_lane2,
+			 int enable_data_lane3, int swap_clock_lane,
+			 int swap_data_lane)
+{
+	register struct nx_mipi_register_set *pregister;
+	register u32 regvalue;
+	u32 newvalue;
+
+	pregister = __g_pregister[module_index];
+	newvalue = (number_of_data_lanes << 5);
+	newvalue |= (enable_clock_lane << 0);
+	newvalue |= (enable_data_lane0 << 1);
+	newvalue |= (enable_data_lane1 << 2);
+	newvalue |= (enable_data_lane2 << 3);
+	newvalue |= (enable_data_lane3 << 4);
+	writereg(dsim_config, 0xFF, newvalue);
+	newvalue = (swap_clock_lane << 1);
+	newvalue |= (swap_data_lane << 0);
+	writereg(dsim_phyacchr1, 0x3, newvalue);
+}
+
+void nx_mipi_dsi_set_pll(u32 module_index, int enable, u32 pllstabletimer,
+			 u32 m_pllpms, u32 m_bandctl, u32 m_dphyctl,
+			 u32 b_dphyctl)
+{
+	register struct nx_mipi_register_set *pregister;
+	register u32 regvalue;
+	u32 newvalue;
+
+	pregister = __g_pregister[module_index];
+	if (!enable) {
+		newvalue = (enable << 23);
+		newvalue |= (m_pllpms << 1);
+		newvalue |= (m_bandctl << 24);
+		writereg(dsim_pllctrl, 0x0FFFFFFF, newvalue);
+	}
+
+	writel(m_dphyctl, &pregister->dsim_phyacchr);
+	writel(pllstabletimer, &pregister->dsim_plltmr);
+	writel((b_dphyctl << 9), &pregister->dsim_phyacchr1);
+
+	if (enable) {
+		newvalue = (enable << 23);
+		newvalue |= (m_pllpms << 1);
+		newvalue |= (m_bandctl << 24);
+		writereg(dsim_pllctrl, 0x0FFFFFFF, newvalue);
+	}
+}
+
+void nx_mipi_dsi_write_pkheader(u32 module_index, u32 data)
+{
+	register struct nx_mipi_register_set *pregister;
+
+	pregister = __g_pregister[module_index];
+	writel(data, &pregister->dsim_pkthdr);
+}
+
+void nx_mipi_dsi_write_payload(u32 module_index, u32 data)
+{
+	register struct nx_mipi_register_set *pregister;
+
+	pregister = __g_pregister[module_index];
+	writel(data, &pregister->dsim_payload);
+}
+
+u32 nx_mipi_dsi_read_fifo_status(u32 module_index)
+{
+	register struct nx_mipi_register_set *pregister;
+
+	pregister = __g_pregister[module_index];
+	return readl(&pregister->dsim_fifoctrl);
+}
drivers/video/nexell/soc/s5pxx18_soc_mipi.h new file +291 -0

291 lines not on this page · raw message

drivers/video/nexell/soc/s5pxx18_soc_mlc.c new file +1861 -0

1,861 lines not on this page · raw message

drivers/video/nexell/soc/s5pxx18_soc_mlc.h new file +429 -0

268 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.9.1

Part of the diff is not shown here. View the raw message.

#16 lore raw

RFC PATCH v2 9/13 video: add nexell video driver (soc: lvds, hdmi)

In reply to Stefan Bosch

Low level functions for LVDS and HDMI display interfaces.

---

Changes in v2: None

 drivers/video/nexell/soc/s5pxx18_soc_hdmi.c |  50 +++
 drivers/video/nexell/soc/s5pxx18_soc_hdmi.h | 488 ++++++++++++++++++++++++++++
 drivers/video/nexell/soc/s5pxx18_soc_lvds.c | 278 ++++++++++++++++
 drivers/video/nexell/soc/s5pxx18_soc_lvds.h |  83 +++++
 4 files changed, 899 insertions(+)
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_hdmi.c
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_hdmi.h
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_lvds.c
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_lvds.h
drivers/video/nexell/soc/s5pxx18_soc_hdmi.c new file +50 -0
new file mode 100644
index 0000000..7b8be7e
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2016  Nexell Co., Ltd.
+ *
+ * Author: junghyun, kim <[email protected]>
+ */
+
+#include <linux/types.h>
+#include <linux/io.h>
+
+#include "s5pxx18_soc_hdmi.h"
+
+static u32 *hdmi_base_addr;
+
+u32 nx_hdmi_get_reg(u32 module_index, u32 offset)
+{
+	u32 *reg_addr;
+	u32 regvalue;
+
+	reg_addr = hdmi_base_addr + (offset / sizeof(u32));
+	regvalue = readl((u32 *)reg_addr);
+
+	return regvalue;
+}
+
+void nx_hdmi_set_reg(u32 module_index, u32 offset, u32 regvalue)
+{
+	s64 offset_new = (s64)((int32_t)offset);
+	u32 *reg_addr;
+
+	reg_addr = hdmi_base_addr + (offset_new / sizeof(u32));
+	writel(regvalue, (u32 *)reg_addr);
+}
+
+void nx_hdmi_set_base_address(u32 module_index, void *base_address)
+{
+	hdmi_base_addr = (u32 *)base_address;
+}
+
+void *nx_hdmi_get_base_address(u32 module_index)
+{
+	return (u32 *)hdmi_base_addr;
+}
+
+u32 nx_hdmi_get_physical_address(u32 module_index)
+{
+	const u32 physical_addr[] = PHY_BASEADDR_HDMI_LIST;
+
+	return physical_addr[module_index];
+}
drivers/video/nexell/soc/s5pxx18_soc_hdmi.h new file +488 -0

488 lines not on this page · raw message

drivers/video/nexell/soc/s5pxx18_soc_lvds.c new file +278 -0

278 lines not on this page · raw message

drivers/video/nexell/soc/s5pxx18_soc_lvds.h new file +83 -0

83 lines not on this page · raw message

Signature · 1 line
1.9.1
#17 lore raw

RFC PATCH v2 10/13 video: add nexell video driver (soc: dpc, makefile)

In reply to Stefan Bosch

Low level functions for DPC (Display Controller) and Makefile for all nexell video low level functions.

---

Changes in v2: None

 drivers/video/nexell/soc/Makefile          |   11 +
 drivers/video/nexell/soc/s5pxx18_soc_dpc.c | 1569 ++++++++++++++++++++++++++++
 drivers/video/nexell/soc/s5pxx18_soc_dpc.h |  444 ++++++++
 3 files changed, 2024 insertions(+)
 create mode 100644 drivers/video/nexell/soc/Makefile
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_dpc.c
 create mode 100644 drivers/video/nexell/soc/s5pxx18_soc_dpc.h
drivers/video/nexell/soc/Makefile new file +11 -0
new file mode 100644
index 0000000..a3036e5
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2016 Nexell
+# Junghyun, kim<[email protected]>
+
+obj-$(CONFIG_VIDEO_NX) += s5pxx18_soc_dpc.o s5pxx18_soc_mlc.o \
+			  s5pxx18_soc_disptop.o s5pxx18_soc_disptop_clk.o
+
+obj-$(CONFIG_VIDEO_NX_LVDS) += s5pxx18_soc_lvds.o
+obj-$(CONFIG_VIDEO_NX_MIPI) += s5pxx18_soc_mipi.o
+obj-$(CONFIG_VIDEO_NX_HDMI) += s5pxx18_soc_hdmi.o
drivers/video/nexell/soc/s5pxx18_soc_dpc.c new file +1569 -0

1,569 lines not on this page · raw message

drivers/video/nexell/soc/s5pxx18_soc_dpc.h new file +444 -0

444 lines not on this page · raw message

Signature · 1 line
1.9.1
#18 lore raw

RFC PATCH v2 11/13 video: add nexell video driver (display/video driver)

In reply to Stefan Bosch

Changes in relation to FriendlyARM's U-Boot nanopi2-v2016.01:
- nexell_display.c: Changed to DM, CONFIG_FB_ADDR can not be used anymore because framebuffer is allocated by video_reserve() in video-uclass.c. Therefore code changed appropriately.

---

Changes in v2: None

 drivers/video/Kconfig                  |  10 +
 drivers/video/Makefile                 |   1 +
 drivers/video/nexell/Kconfig           |  27 ++
 drivers/video/nexell/Makefile          |  12 +
 drivers/video/nexell/s5pxx18_dp.c      | 338 ++++++++++++++++
 drivers/video/nexell/s5pxx18_dp_hdmi.c | 543 ++++++++++++++++++++++++++
 drivers/video/nexell/s5pxx18_dp_lvds.c | 274 +++++++++++++
 drivers/video/nexell/s5pxx18_dp_mipi.c | 677 +++++++++++++++++++++++++++++++++
 drivers/video/nexell/s5pxx18_dp_rgb.c  |  69 ++++
 drivers/video/nexell_display.c         | 665 ++++++++++++++++++++++++++++++++
 10 files changed, 2616 insertions(+)
 create mode 100644 drivers/video/nexell/Kconfig
 create mode 100644 drivers/video/nexell/Makefile
 create mode 100644 drivers/video/nexell/s5pxx18_dp.c
 create mode 100644 drivers/video/nexell/s5pxx18_dp_hdmi.c
 create mode 100644 drivers/video/nexell/s5pxx18_dp_lvds.c
 create mode 100644 drivers/video/nexell/s5pxx18_dp_mipi.c
 create mode 100644 drivers/video/nexell/s5pxx18_dp_rgb.c
 create mode 100644 drivers/video/nexell_display.c
drivers/video/Kconfig +10 -0
index 50ab365..dd224ab 100644
@@ -563,6 +563,16 @@ source "drivers/video/bridge/Kconfig"
 
 source "drivers/video/imx/Kconfig"
 
+config VIDEO_NX
+	bool "Enable video support on Nexell SoC"
+	depends on ARCH_S5P6818 || ARCH_S5P4418
+	help
+	   Nexell SoC supports many video output options including eDP and
+	   HDMI. This option enables this support which can be used on devices
+	   which have an eDP display connected.
+
+source "drivers/video/nexell/Kconfig"
+
 config VIDEO
 	bool "Enable legacy video support"
 	depends on !DM_VIDEO
drivers/video/Makefile +1 -0
index df7119d..3bacc64 100644
@@ -61,6 +61,7 @@ obj-${CONFIG_VIDEO_MIPI_DSI} += mipi_dsi.o
 obj-$(CONFIG_VIDEO_MVEBU) += mvebu_lcd.o
 obj-$(CONFIG_VIDEO_MX3) += mx3fb.o videomodes.o
 obj-$(CONFIG_VIDEO_MXS) += mxsfb.o videomodes.o
+obj-$(CONFIG_VIDEO_NX) += nexell_display.o videomodes.o nexell/
 obj-$(CONFIG_VIDEO_OMAP3) += omap3_dss.o
 obj-$(CONFIG_VIDEO_DSI_HOST_SANDBOX) += sandbox_dsi_host.o
 obj-$(CONFIG_VIDEO_SANDBOX_SDL) += sandbox_sdl.o
drivers/video/nexell/Kconfig new file +27 -0
new file mode 100644
index 0000000..54b8ccb
@@ -0,0 +1,27 @@
+if VIDEO_NX
+
+menu "LCD select"
+
+config VIDEO_NX_RGB
+	bool "RGB LCD"
+	help
+	  Support for RGB lcd output.
+
+config VIDEO_NX_LVDS
+	bool "LVDS LCD"
+	help
+	  Support for LVDS lcd output.
+
+config VIDEO_NX_MIPI
+	bool "MiPi"
+	help
+	  Support for MiPi lcd output.
+
+config VIDEO_NX_HDMI
+	bool "HDMI"
+	help
+	  Support for hdmi output.
+
+endmenu
+
+endif
drivers/video/nexell/Makefile new file +12 -0
new file mode 100644
index 0000000..111ab45
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2016 Nexell
+# Junghyun, kim<[email protected]>
+
+obj-$(CONFIG_VIDEO_NX) += s5pxx18_dp.o
+obj-$(CONFIG_VIDEO_NX) += soc/
+
+obj-$(CONFIG_VIDEO_NX_RGB)  += s5pxx18_dp_rgb.o
+obj-$(CONFIG_VIDEO_NX_LVDS) += s5pxx18_dp_lvds.o
+obj-$(CONFIG_VIDEO_NX_MIPI) += s5pxx18_dp_mipi.o
+obj-$(CONFIG_VIDEO_NX_HDMI) += s5pxx18_dp_hdmi.o
drivers/video/nexell/s5pxx18_dp.c new file +338 -0

338 lines not on this page · raw message

drivers/video/nexell/s5pxx18_dp_hdmi.c new file +543 -0

543 lines not on this page · raw message

drivers/video/nexell/s5pxx18_dp_lvds.c new file +274 -0

274 lines not on this page · raw message

drivers/video/nexell/s5pxx18_dp_mipi.c new file +677 -0

677 lines not on this page · raw message

drivers/video/nexell/s5pxx18_dp_rgb.c new file +69 -0

69 lines not on this page · raw message

drivers/video/nexell_display.c new file +665 -0

665 lines not on this page · raw message

Signature · 1 line
1.9.1
#19 lore raw

RFC PATCH v2 12/13 arm: add support for SoC s5p4418 (cpu) / nanopi2 board

In reply to Stefan Bosch

Changes in relation to FriendlyARM's U-Boot nanopi2-v2016.01:
- SPL not supported yet --> no spl-dir in arch/arm/cpu/armv7/s5p4418/. Appropriate line in Makefile removed.
- cpu.c: '#include <cpu_func.h>' added.
- arch/arm/cpu/armv7/s5p4418/u-boot.lds removed, is not required anylonger.
- "obj-$(CONFIG_ARCH_NEXELL) += s5p-common/" added to arch/arm/cpu/armv7/Makefile since s5p-common/pwm.c is used instead of drivers/pwm/pwm-nexell.c.
- s5p4418.dtsi: '#include "../../../include/generated/autoconf.h"' removed, is not necessary, error at out-of-tree building. '#ifdef CONFIG_CPU_NXP4330'-blocks (2x) removed. Some minor changes regarding mmc. 'u-boot,dm-pre-reloc' added to dp0 because of added DM_VIDEO support.
- board/s5p4418/ renamed to board/friendlyarm/
- All s5p4418-boards except nanopi2 removed because there is no possibility to test the other boards.
- Kconfig: Changes to have a structure like mach-bcm283x (RaspberryPi), e.g. "config ..." entries moved from/to other Kconfig.
- "CONFIG_" removed from several s5p4418/nanopi2 specific defines because the appropriate values do not need to be configurable.
- nanopi2/board.c: All getenv(), getenv_ulong(), setenv() and saveenv() renamed to env_get(), env_get_ulong(), env_set() and env_save(), respectively. MACH_TYPE_S5P4418 is not defined anymore, therefore appropriate code removed (not necessary for DT-kernels).
- nanopi2/onewire.c: All crc8() renamed to crc8_ow() because crc8() is already defined in lib/crc8.c (with different parameters).
- dts: "nexell,s5pxx18-i2c" used instead of "i2c-gpio", i2c0 and i2c1 added. s5p4418-pinctrl.dtsi not included because there is no pinctrl-driver available. gmac-, ehci- and dwc2otg-entries removed because the appropriate functionality is not supported yet.

---

Changes in v2:
- i2c: "nexell,s5pxx18-i2c"-driver is used now instead of "i2c-gpio". i2c0 and i2c1 added. I.e. dts files changed appropriately.
- dts: gmac-, ehci- and dwc2otg-entries removed because the appropriate functionality is not supported yet.
- s5p4418-pinctrl.dtsi removed because there is no pinctrl-driver available.
- "obj-$(CONFIG_ARCH_NEXELL) += s5p-common/" added to arch/arm/cpu/armv7/Makefile since s5p-common/pwm.c is used now instead of drivers/pwm/pwm-nexell.c.
- cosmetic: additional GPL license text removed, SPDX-License-Identifier is enough. Furthermore file path removed (two files).

 arch/arm/cpu/armv7/Makefile           |   2 +
 arch/arm/cpu/armv7/s5p4418/Makefile   |   6 +
 arch/arm/cpu/armv7/s5p4418/cpu.c      | 120 ++++++
 arch/arm/dts/Makefile                 |   3 +
 arch/arm/dts/s5p4418-nanopi2.dts      | 108 ++++++
 arch/arm/dts/s5p4418.dtsi             | 148 ++++++++
 board/friendlyarm/Kconfig             |  39 ++
 board/friendlyarm/nanopi2/Kconfig     |  12 +
 board/friendlyarm/nanopi2/MAINTAINERS |   7 +
 board/friendlyarm/nanopi2/Makefile    |   6 +
 board/friendlyarm/nanopi2/board.c     | 567 +++++++++++++++++++++++++++
 board/friendlyarm/nanopi2/hwrev.c     | 108 ++++++
 board/friendlyarm/nanopi2/hwrev.h     |  15 +
 board/friendlyarm/nanopi2/lcds.c      | 697 ++++++++++++++++++++++++++++++++++
 board/friendlyarm/nanopi2/nxp-fb.h    |  94 +++++
 board/friendlyarm/nanopi2/onewire.c   | 309 +++++++++++++++
 board/friendlyarm/nanopi2/onewire.h   |  15 +
 17 files changed, 2256 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/s5p4418/Makefile
 create mode 100644 arch/arm/cpu/armv7/s5p4418/cpu.c
 create mode 100644 arch/arm/dts/s5p4418-nanopi2.dts
 create mode 100644 arch/arm/dts/s5p4418.dtsi
 create mode 100644 board/friendlyarm/Kconfig
 create mode 100644 board/friendlyarm/nanopi2/Kconfig
 create mode 100644 board/friendlyarm/nanopi2/MAINTAINERS
 create mode 100644 board/friendlyarm/nanopi2/Makefile
 create mode 100644 board/friendlyarm/nanopi2/board.c
 create mode 100644 board/friendlyarm/nanopi2/hwrev.c
 create mode 100644 board/friendlyarm/nanopi2/hwrev.h
 create mode 100644 board/friendlyarm/nanopi2/lcds.c
 create mode 100644 board/friendlyarm/nanopi2/nxp-fb.h
 create mode 100644 board/friendlyarm/nanopi2/onewire.c
 create mode 100644 board/friendlyarm/nanopi2/onewire.h
arch/arm/cpu/armv7/Makefile +2 -0
index 8c955d0..0e83e39 100644
@@ -42,3 +42,5 @@ obj-$(CONFIG_RMOBILE) += rmobile/
 obj-$(if $(filter stv0991,$(SOC)),y) += stv0991/
 obj-$(CONFIG_ARCH_SUNXI) += sunxi/
 obj-$(CONFIG_VF610) += vf610/
+obj-$(CONFIG_ARCH_S5P4418) += s5p4418/
+obj-$(CONFIG_ARCH_NEXELL) += s5p-common/
arch/arm/cpu/armv7/s5p4418/Makefile new file +6 -0
new file mode 100644
index 0000000..321b257
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2016 Nexell
+# Hyunseok, Jung <[email protected]>
+
+obj-y += cpu.o
arch/arm/cpu/armv7/s5p4418/cpu.c new file +120 -0

120 lines not on this page · raw message

arch/arm/dts/Makefile +3 -0
index 04a8ccc..065b2d2 100644
@@ -137,6 +137,9 @@ dtb-$(CONFIG_ROCKCHIP_RV1108) += \
 	rv1108-elgin-r1.dtb \
 	rv1108-evb.dtb
 
+dtb-$(CONFIG_ARCH_S5P4418) += \
+	s5p4418-nanopi2.dtb
+
 dtb-$(CONFIG_ARCH_MESON) += \
 	meson-gxbb-nanopi-k2.dtb \
 	meson-gxbb-odroidc2.dtb \
arch/arm/dts/s5p4418-nanopi2.dts new file +108 -0

108 lines not on this page · raw message

arch/arm/dts/s5p4418.dtsi new file +148 -0

148 lines not on this page · raw message

board/friendlyarm/Kconfig new file +39 -0
new file mode 100644
index 0000000..8f79640
@@ -0,0 +1,39 @@
+
+#config SYS_CONFIG_NAME
+#	string "Board header file"
+#	help
+#	  This option should contain the base name of board header file.
+#	  The header file include/configs/<CONFIG_SYS_CONFIG_NAME>.h
+#	  should be included from include/config.h.
+
+config S5P4418_ONEWIRE
+	bool "S5P4418_ONEWIRE"
+	#default y
+
+config PWM_NX
+	bool "PWM_NX"
+	#default y
+
+config SYS_RESERVE_MEM_SIZE
+	hex "SYS_RESERVE_MEM_SIZE"
+
+config ROOT_DEV
+	int "ROOT_DEV"
+	help
+	  Environment variable rootdev is set to this value if env. var. firstboot
+	  does not exist. Otherwise rootdev is set to the MMC boot device. rootdev
+	  determines (together with env. var. bootpart) where the OS (linux) is
+	  booted from.
+
+config BOOT_PART
+	int "BOOT_PART"
+	help
+	  Environment variable bootpart is set to this value. bootpart determines
+	  (together with env. var. rootdev) where the OS (linux) is booted from.
+
+config ROOT_PART
+	int "ROOT_PART"
+	help
+	  Environment variable rootpart is set to this value.
+
+source "board/friendlyarm/nanopi2/Kconfig"
board/friendlyarm/nanopi2/Kconfig new file +12 -0
new file mode 100644
index 0000000..0f68422
@@ -0,0 +1,12 @@
+if TARGET_NANOPI2
+
+config SYS_BOARD
+	default "nanopi2"
+
+config SYS_VENDOR
+	default "friendlyarm"
+
+config SYS_CONFIG_NAME
+	default "s5p4418_nanopi2"
+
+endif
board/friendlyarm/nanopi2/MAINTAINERS new file +7 -0
new file mode 100644
index 0000000..c8e2ce7
@@ -0,0 +1,7 @@
+NANOPI2 BOARD
+NANOPC-T2 BOARD
+M:  Stefan Bosch <[email protected]>
+S:  Maintained
+F:  board/s5p4418/nanopi2/
+F:  include/configs/s5p4418_nanopi2.h
+F:  configs/s5p4418_nanopi2_defconfig
board/friendlyarm/nanopi2/Makefile new file +6 -0
new file mode 100644
index 0000000..cd459f2
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2016 Nexell
+# Hyunseok, Jung <[email protected]>
+
+obj-y	:= board.o hwrev.o onewire.o lcds.o
board/friendlyarm/nanopi2/board.c new file +567 -0

567 lines not on this page · raw message

board/friendlyarm/nanopi2/hwrev.c new file +108 -0

108 lines not on this page · raw message

board/friendlyarm/nanopi2/hwrev.h new file +15 -0
new file mode 100644
index 0000000..1b1a828
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0+
+ *
+ * Copyright (C) Guangzhou FriendlyARM Computer Tech. Co., Ltd.
+ * (http://www.friendlyarm.com)
+ */
+
+#ifndef __BD_HW_REV_H__
+#define __BD_HW_REV_H__
+
+extern void bd_hwrev_init(void);
+extern void bd_base_rev_init(void);
+extern u32 get_board_rev(void);
+extern const char *get_board_name(void);
+
+#endif /* __BD_HW_REV_H__ */
board/friendlyarm/nanopi2/lcds.c new file +697 -0

697 lines not on this page · raw message

board/friendlyarm/nanopi2/nxp-fb.h new file +94 -0

94 lines not on this page · raw message

board/friendlyarm/nanopi2/onewire.c new file +309 -0

309 lines not on this page · raw message

board/friendlyarm/nanopi2/onewire.h new file +15 -0
new file mode 100644
index 0000000..9f6d7cf
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0+
+ *
+ * Copyright (C) Guangzhou FriendlyARM Computer Tech. Co., Ltd.
+ * (http://www.friendlyarm.com)
+ */
+
+#ifndef __ONE_WIRE_H__
+#define __ONE_WIRE_H__
+
+extern void onewire_init(void);
+extern int  onewire_get_info(unsigned char *lcd, unsigned short *fw_ver);
+extern int  onewire_get_lcd_id(void);
+extern int  onewire_set_backlight(int brightness);
+
+#endif /* __ONE_WIRE_H__ */
Signature · 1 line
1.9.1
#20 lore raw

RFC PATCH v2 13/13 arm: add (default) config for nanopi2 board

In reply to Stefan Bosch

Changes in relation to FriendlyARM's U-Boot nanopi2-v2016.01:
- Configuration changed, mainly several "CONFIG_..." moved from s5p4418_nanopi2.h to s5p4418_nanopi2_defconfig and USB related configs removed because USB is not supported yet.
- s5p4418_nanopi2.h: "CONFIG_" removed from several s5p4418/nanopi2 specific defines because the appropriate values do not need to be configurable.

---

Changes in v2:
- USB related configs removed because USB is not supported yet.
- CONFIG_CMD_MEMTEST moved from s5p4418_nanopi2.h to s5p4418_nanopi2_defconfig.
- MAINTAINERS: "F: drivers/pwm/pwm-nexell*" deleted because arch/arm/cpu/armv7/s5p-common/pwm.c is used now. Furthermore double line "F: drivers/video/nexell/" deleted.

 MAINTAINERS                       |  16 +++
 configs/s5p4418_nanopi2_defconfig | 148 +++++++++++++++++++++
 doc/README.s5p4418                |  63 +++++++++
 include/configs/s5p4418_nanopi2.h | 265 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 492 insertions(+)
 create mode 100644 configs/s5p4418_nanopi2_defconfig
 create mode 100644 doc/README.s5p4418
 create mode 100644 include/configs/s5p4418_nanopi2.h
MAINTAINERS +16 -0
index 7d2729d..9d1acb7 100644
@@ -258,6 +258,22 @@ F:	arch/arm/mach-at91/
 F:	board/atmel/
 F:	drivers/misc/microchip_flexcom.c
 
+ARM NEXELL S5P4418
+M:	Stefan Bosch <[email protected]>
+S:	Maintained
+F:	arch/arm/cpu/armv7/s5p4418/
+F:	arch/arm/dts/s5p4418*
+F:	arch/arm/mach-nexell/
+F:	board/friendlyarm/
+F:	configs/s5p4418_nanopi2_defconfig
+F:	doc/README.s5p4418
+F:	drivers/gpio/nx_gpio.c
+F:	drivers/i2c/nx_i2c.c
+F:	drivers/mmc/nexell_dw_mmc_dm.c
+F:	drivers/video/nexell/
+F:	drivers/video/nexell_display.c
+F:	include/configs/s5p4418_nanopi2.h
+
 ARM OWL
 M:	Manivannan Sadhasivam <[email protected]>
 S:	Maintained
configs/s5p4418_nanopi2_defconfig new file +148 -0

148 lines not on this page · raw message

doc/README.s5p4418 new file +63 -0

63 lines not on this page · raw message

include/configs/s5p4418_nanopi2.h new file +265 -0

265 lines not on this page · raw message

Signature · 1 line
1.9.1