Add Amlogic Meson SPI Flash Controller driver
Subsystems (2)
v3 cover Add Amlogic Meson SPI Flash Controller driver
The Amlogic Meson SoCs embeds a Flash oriented SPI Controller name SPIFC.
This patchset add the driver ported from linux, but also import the regmap regmap_read_poll_timeout() to implify the register polling in the driver.
Neil Armstrong (3):
regmap: add regmap_read_poll_timeout() helper
test: regmap: add regmap_read_poll_timeout test
spi: Add Amlogic Meson SPI Flash Controller driver
drivers/spi/Kconfig | 8 + drivers/spi/Makefile | 1 + drivers/spi/meson_spifc.c | 320 ++++++++++++++++++++++++++++++++++++++ include/regmap.h | 38 +++++ test/dm/regmap.c | 26 ++++ 5 files changed, 393 insertions(+) create mode 100644 drivers/spi/meson_spifc.c
Signature · 1 line
2.19.1
PATCH v3 1/3 regmap: add regmap_read_poll_timeout() helper
Add the regmap_read_poll_timeout() macro based on the Linux implementation to simplify register polling with configurable timeout and sleep.
--- include/regmap.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
include/regmap.h +38 -0
@@ -239,6 +239,44 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,#define regmap_get (map, type, member, valp) \ regmap_range_get(map, 0, type, member, valp) +/** +* regmap_read_poll_timeout - Poll until a condition is met or a timeout occurs +* +* @map: Regmap to read from +* @addr: Offset to poll +* @val: Unsigned integer variable to read the value into +* @cond: Break condition (usually involving @val) +* @sleep_us: Maximum time to sleep between reads in us (0 tight-loops). +* @timeout_ms: Timeout in ms, 0 means never timeout +* +* Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read +* error return value in case of a error read. In the two former cases, +* the last read value at @addr is stored in @val. Must not be called +* from atomic context if sleep_us or timeout_us are used. +* +* This is modelled after the regmap_read_poll_timeout macros in linux but +* with millisecond timeout. +*/ +#define regmap_read_poll_timeout (map, addr, val, cond, sleep_us, timeout_ms) \ +({ \ + unsigned long __start = get_timer(0); \ + int __ret; \ + for (;;) { \ + __ret = regmap_read((map), (addr), &(val)); \ + if (__ret) \ + break; \ + if (cond) \ + break; \ + if ((timeout_ms) && get_timer(__start) > (timeout_ms)) { \ + __ret = regmap_read((map), (addr), &(val)); \ + break; \ + } \ + if ((sleep_us)) \ + udelay((sleep_us)); \ + } \ + __ret ?: ((cond) ? 0 : -ETIMEDOUT); \ +}) +/** * regmap_update_bits() - Perform a read/modify/write using a mask *
Signature · 1 line
2.19.1
PATCH v3 1/3 regmap: add regmap_read_poll_timeout() helper
Hi Neil,
Quoted 10 lines · Neil Armstrong
Add the
regmap_read_poll_timeout()macro based on the Linux implementation to simplify register polling with configurable timeout and sleep.Acked-by Jagan Teki <[email protected]>Signed-off-by Neil Armstrong <[email protected]>--- include/regmap.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
Is there a change log somewhere? This is v3.
Regards,
Simon
PATCH v3 1/3 regmap: add regmap_read_poll_timeout() helper
Hi Simon,
Quoted 7 lines · Simon Glass
Hi Neil,
Quoted 4 lines · Neil Armstrong
Add the
regmap_read_poll_timeout()macro based on the Linux implementation to simplify register polling with configurable timeout and sleep.
Quoted 8 lines
Quoted 6 lines
Acked-by Jagan Teki <[email protected]>Signed-off-by Neil Armstrong <[email protected]>--- include/regmap.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)Is there a change log somewhere? This is v3.
Forgot changelog on cover letter, v3 only changes the SPI driver, the regmap patches are only rebased against master.
Neil
Quoted 4 lines
Regards,
Simon
PATCH v3 2/3 test: regmap: add regmap_read_poll_timeout test
In reply to Neil ArmstrongAdd test to regmap_read_poll_timeout() helper to check the timeout works properly but cannot test proper condition matching since read/write calls are not executed in sandbox.
--- test/dm/regmap.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
test/dm/regmap.c +26 -0
@@ -144,3 +144,29 @@ static int dm_test_regmap_getset(struct unit_test_state *uts) }DM_TEST (dm_test_regmap_getset,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); + +/* Read polling test */ +static int dm_test_regmap_poll (struct unit_test_state *uts) +{ +struct udevice *dev; +struct regmap *map; +uint reg; +unsigned long start; + +ut_assertok (uclass_get_device (UCLASS_SYSCON ,0 , &dev)); + map =syscon_get_regmap (dev); +ut_assertok_ptr (map); + + start =get_timer (0 ); + +ut_asserteq (-ETIMEDOUT , +regmap_read_poll_timeout (map,0 , reg, + (reg ==0xcacafafa ), +1 ,5 *CONFIG_SYS_HZ )); + +ut_assert (get_timer (start) > (5 *CONFIG_SYS_HZ )); + +return 0 ; +} + +DM_TEST (dm_test_regmap_poll,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT );
Signature · 1 line
2.19.1
PATCH v3 3/3 spi: Add Amlogic Meson SPI Flash Controller driver
In reply to Neil ArmstrongThe Amlogic Meson SoCs embeds a Flash oriented SPI Controller name SPIFC. This driver, ported from the Linux meson-spi-spifc driver, add support for this controller on the Amlogic Meson GX SoCs in U-Boot.
--- drivers/spi/Kconfig | 8 + drivers/spi/Makefile | 1 + drivers/spi/meson_spifc.c | 320 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 329 insertions(+) create mode 100644 drivers/spi/meson_spifc.c
drivers/spi/Kconfig +8 -0
@@ -116,6 +116,14 @@ config ICH_SPI access the SPI NOR flash on platforms embedding this Intel ICH IP core. +config MESON_SPIFC + bool "Amlogic Meson SPI Flash Controller driver" + depends on ARCH_MESON + help + Enable the Amlogic Meson SPI Flash Controller SPIFC) driver. + This driver can be used to access the SPI NOR flash chips on + Amlogic Meson SoCs. + config MT7621_SPI bool "MediaTek MT7621 SPI driver" depends on ARCH_MT7620
drivers/spi/Makefile +1 -0
@@ -31,6 +31,7 @@ obj-$(CONFIG_FSL_QSPI) += fsl_qspi.o obj-$(CONFIG_ICH_SPI) += ich.o obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o obj-$(CONFIG_LPC32XX_SSP) += lpc32xx_ssp.o +obj-$(CONFIG_MESON_SPIFC) += meson_spifc.o obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o obj-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o obj-$(CONFIG_MT7621_SPI) += mt7621_spi.o
drivers/spi/meson_spifc.c new file +320 -0
320 lines not on this page · raw message
Signature · 1 line
2.19.1
v3 cover Add Amlogic Meson SPI Flash Controller driver
In reply to Neil ArmstrongQuoted 10 lines · Neil Armstrong
The Amlogic Meson SoCs embeds a Flash oriented SPI Controller name SPIFC.
This patchset add the driver ported from linux, but also import the regmap
regmap_read_poll_timeout()to implify the register polling in the driver.Neil Armstrong (3):
regmap: addregmap_read_poll_timeout()helper
test: regmap: addregmap_read_poll_timeouttest
spi: Add Amlogic Meson SPI Flash Controller driver
Applied to u-boot-spi/master