diff options
author | Tom Rini <trini@konsulko.com> | 2020-05-11 08:27:55 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-05-11 08:27:55 -0400 |
commit | 951db64186b2b9ad2e3ee30e2093deea005bdd8a (patch) | |
tree | 044159f0c87de5022dc6d83f300e27eec2fbc1fd | |
parent | c5c657644bc35fd6b3d6e5517698721e90646b8d (diff) | |
parent | 8af1caa23728ef689d095eec1ec4e6f1d46f50e4 (diff) | |
download | u-boot-951db64186b2b9ad2e3ee30e2093deea005bdd8a.zip u-boot-951db64186b2b9ad2e3ee30e2093deea005bdd8a.tar.gz u-boot-951db64186b2b9ad2e3ee30e2093deea005bdd8a.tar.bz2 |
Merge branch 'master' of https://gitlab.denx.de/u-boot/custodians/u-boot-spi
- zap lpc32xx_ssp driver (Jagan)
- rename of phy nodev call (Jagan)
- iopoll with sleep_us (Jagan)
- MX25R6435F flash (Ye Li)
-rw-r--r-- | arch/arm/mach-meson/board-gx.c | 3 | ||||
-rw-r--r-- | drivers/mtd/spi/spi-nor-core.c | 19 | ||||
-rw-r--r-- | drivers/mtd/spi/spi-nor-ids.c | 1 | ||||
-rw-r--r-- | drivers/phy/phy-uclass.c | 4 | ||||
-rw-r--r-- | drivers/spi/Kconfig | 6 | ||||
-rw-r--r-- | drivers/spi/Makefile | 1 | ||||
-rw-r--r-- | drivers/spi/lpc32xx_ssp.c | 134 | ||||
-rw-r--r-- | drivers/spi/nxp_fspi.c | 10 | ||||
-rw-r--r-- | include/clk.h | 12 | ||||
-rw-r--r-- | include/configs/devkit3250.h | 5 | ||||
-rw-r--r-- | include/configs/work_92105.h | 5 | ||||
-rw-r--r-- | include/generic-phy.h | 9 | ||||
-rw-r--r-- | include/linux/iopoll.h | 16 | ||||
-rw-r--r-- | scripts/config_whitelist.txt | 1 |
14 files changed, 47 insertions, 179 deletions
diff --git a/arch/arm/mach-meson/board-gx.c b/arch/arm/mach-meson/board-gx.c index 3da9901..b591c92 100644 --- a/arch/arm/mach-meson/board-gx.c +++ b/arch/arm/mach-meson/board-gx.c @@ -183,7 +183,8 @@ int board_usb_init(int index, enum usb_init_type init) /* get the PHYs */ for (i = 0; i < 2; i++) { - ret = generic_phy_get_by_node(dwc2_node, i, &usb_phys[i]); + ret = generic_phy_get_by_index_nodev(dwc2_node, i, + &usb_phys[i]); if (ret && ret != -ENOENT) { pr_err("Failed to get USB PHY%d for %s\n", i, ofnode_get_name(dwc2_node)); diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index e840c60..3d43614 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -56,8 +56,7 @@ static int spi_nor_read_reg(struct spi_nor *nor, u8 code, u8 *val, int len) ret = spi_nor_read_write_reg(nor, &op, val); if (ret < 0) - dev_dbg(&flash->spimem->spi->dev, "error %d reading %x\n", ret, - code); + dev_dbg(nor->dev, "error %d reading %x\n", ret, code); return ret; } @@ -1374,7 +1373,8 @@ static int spansion_read_cr_quad_enable(struct spi_nor *nor) /* Check current Quad Enable bit value. */ ret = read_cr(nor); if (ret < 0) { - dev_dbg(dev, "error while reading configuration register\n"); + dev_dbg(nor->dev, + "error while reading configuration register\n"); return -EINVAL; } @@ -1386,7 +1386,7 @@ static int spansion_read_cr_quad_enable(struct spi_nor *nor) /* Keep the current value of the Status Register. */ ret = read_sr(nor); if (ret < 0) { - dev_dbg(dev, "error while reading status register\n"); + dev_dbg(nor->dev, "error while reading status register\n"); return -EINVAL; } sr_cr[0] = ret; @@ -2069,7 +2069,8 @@ static int spi_nor_parse_sfdp(struct spi_nor *nor, err = spi_nor_read_sfdp(nor, sizeof(header), psize, param_headers); if (err < 0) { - dev_err(dev, "failed to read SFDP parameter headers\n"); + dev_err(nor->dev, + "failed to read SFDP parameter headers\n"); goto exit; } } @@ -2099,7 +2100,8 @@ static int spi_nor_parse_sfdp(struct spi_nor *nor, switch (SFDP_PARAM_HEADER_ID(param_header)) { case SFDP_SECTOR_MAP_ID: - dev_info(dev, "non-uniform erase sector maps are not supported yet.\n"); + dev_info(nor->dev, + "non-uniform erase sector maps are not supported yet.\n"); break; case SFDP_SST_ID: @@ -2111,7 +2113,8 @@ static int spi_nor_parse_sfdp(struct spi_nor *nor, } if (err) { - dev_warn(dev, "Failed to parse optional parameter table: %04x\n", + dev_warn(nor->dev, + "Failed to parse optional parameter table: %04x\n", SFDP_PARAM_HEADER_ID(param_header)); /* * Let's not drop all information we extracted so far @@ -2609,7 +2612,7 @@ int spi_nor_scan(struct spi_nor *nor) } if (nor->addr_width > SPI_NOR_MAX_ADDR_WIDTH) { - dev_dbg(dev, "address width is too large: %u\n", + dev_dbg(nor->dev, "address width is too large: %u\n", nor->addr_width); return -EINVAL; } diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c index e5e7102..114ebac 100644 --- a/drivers/mtd/spi/spi-nor-ids.c +++ b/drivers/mtd/spi/spi-nor-ids.c @@ -160,6 +160,7 @@ const struct flash_info spi_nor_ids[] = { { INFO("mx66u2g45g", 0xc2253c, 0, 64 * 1024, 4096, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, { INFO("mx66l1g45g", 0xc2201b, 0, 64 * 1024, 2048, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { INFO("mx25l1633e", 0xc22415, 0, 64 * 1024, 32, SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES | SECT_4K) }, + { INFO("mx25r6435f", 0xc22817, 0, 64 * 1024, 128, SECT_4K) }, #endif #ifdef CONFIG_SPI_FLASH_STMICRO /* STMICRO */ diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c index 6ab7844..1fded5e 100644 --- a/drivers/phy/phy-uclass.c +++ b/drivers/phy/phy-uclass.c @@ -32,7 +32,7 @@ static int generic_phy_xlate_offs_flags(struct phy *phy, return 0; } -int generic_phy_get_by_node(ofnode node, int index, struct phy *phy) +int generic_phy_get_by_index_nodev(ofnode node, int index, struct phy *phy) { struct ofnode_phandle_args args; struct phy_ops *ops; @@ -94,7 +94,7 @@ err: int generic_phy_get_by_index(struct udevice *dev, int index, struct phy *phy) { - return generic_phy_get_by_node(dev_ofnode(dev), index, phy); + return generic_phy_get_by_index_nodev(dev_ofnode(dev), index, phy); } int generic_phy_get_by_name(struct udevice *dev, const char *phy_name, diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 4166c61..dccd5ea 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -431,12 +431,6 @@ config KIRKWOOD_SPI Enable support for SPI on various Marvell SoCs, such as Kirkwood and Armada 375. -config LPC32XX_SSP - bool "LPC32XX SPI Driver" - depends on DEPRECATED - help - Enable support for SPI on LPC32xx - config MXC_SPI bool "MXC SPI Driver" help diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index 52462e1..6441694 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile @@ -33,7 +33,6 @@ obj-$(CONFIG_FSL_ESPI) += fsl_espi.o 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 diff --git a/drivers/spi/lpc32xx_ssp.c b/drivers/spi/lpc32xx_ssp.c deleted file mode 100644 index 4b09366..0000000 --- a/drivers/spi/lpc32xx_ssp.c +++ /dev/null @@ -1,134 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * LPC32xx SSP interface (SPI mode) - * - * (C) Copyright 2014 DENX Software Engineering GmbH - * Written-by: Albert ARIBAUD <albert.aribaud@3adev.fr> - */ - -#include <common.h> -#include <linux/compat.h> -#include <asm/io.h> -#include <malloc.h> -#include <spi.h> -#include <asm/arch/clk.h> - -/* SSP chip registers */ -struct ssp_regs { - u32 cr0; - u32 cr1; - u32 data; - u32 sr; - u32 cpsr; - u32 imsc; - u32 ris; - u32 mis; - u32 icr; - u32 dmacr; -}; - -/* CR1 register defines */ -#define SSP_CR1_SSP_ENABLE 0x0002 - -/* SR register defines */ -#define SSP_SR_TNF 0x0002 -/* SSP status RX FIFO not empty bit */ -#define SSP_SR_RNE 0x0004 - -/* lpc32xx spi slave */ -struct lpc32xx_spi_slave { - struct spi_slave slave; - struct ssp_regs *regs; -}; - -static inline struct lpc32xx_spi_slave *to_lpc32xx_spi_slave( - struct spi_slave *slave) -{ - return container_of(slave, struct lpc32xx_spi_slave, slave); -} - -/* the following is called in sequence by do_spi_xfer() */ - -struct spi_slave *spi_setup_slave(uint bus, uint cs, uint max_hz, uint mode) -{ - struct lpc32xx_spi_slave *lslave; - - /* we only set up SSP0 for now, so ignore bus */ - - if (mode & SPI_3WIRE) { - pr_err("3-wire mode not supported"); - return NULL; - } - - if (mode & SPI_SLAVE) { - pr_err("slave mode not supported\n"); - return NULL; - } - - if (mode & SPI_PREAMBLE) { - pr_err("preamble byte skipping not supported\n"); - return NULL; - } - - lslave = spi_alloc_slave(struct lpc32xx_spi_slave, bus, cs); - if (!lslave) { - printf("SPI_error: Fail to allocate lpc32xx_spi_slave\n"); - return NULL; - } - - lslave->regs = (struct ssp_regs *)SSP0_BASE; - - /* - * 8 bit frame, SPI fmt, 500kbps -> clock divider is 26. - * Set SCR to 0 and CPSDVSR to 26. - */ - - writel(0x7, &lslave->regs->cr0); /* 8-bit chunks, SPI, 1 clk/bit */ - writel(26, &lslave->regs->cpsr); /* SSP clock = HCLK/26 = 500kbps */ - writel(0, &lslave->regs->imsc); /* do not raise any interrupts */ - writel(0, &lslave->regs->icr); /* clear any pending interrupt */ - writel(0, &lslave->regs->dmacr); /* do not do DMAs */ - writel(SSP_CR1_SSP_ENABLE, &lslave->regs->cr1); /* enable SSP0 */ - return &lslave->slave; -} - -void spi_free_slave(struct spi_slave *slave) -{ - struct lpc32xx_spi_slave *lslave = to_lpc32xx_spi_slave(slave); - - debug("(lpc32xx) spi_free_slave: 0x%08x\n", (u32)lslave); - free(lslave); -} - -int spi_claim_bus(struct spi_slave *slave) -{ - /* only one bus and slave so far, always available */ - return 0; -} - -int spi_xfer(struct spi_slave *slave, unsigned int bitlen, - const void *dout, void *din, unsigned long flags) -{ - struct lpc32xx_spi_slave *lslave = to_lpc32xx_spi_slave(slave); - int bytelen = bitlen >> 3; - int idx_out = 0; - int idx_in = 0; - int start_time; - - start_time = get_timer(0); - while ((idx_out < bytelen) || (idx_in < bytelen)) { - int status = readl(&lslave->regs->sr); - if ((idx_out < bytelen) && (status & SSP_SR_TNF)) - writel(((u8 *)dout)[idx_out++], &lslave->regs->data); - if ((idx_in < bytelen) && (status & SSP_SR_RNE)) - ((u8 *)din)[idx_in++] = readl(&lslave->regs->data); - if (get_timer(start_time) >= CONFIG_LPC32XX_SSP_TIMEOUT) - return -1; - } - return 0; -} - -void spi_release_bus(struct spi_slave *slave) -{ - /* do nothing */ -} diff --git a/drivers/spi/nxp_fspi.c b/drivers/spi/nxp_fspi.c index 0e6c7be..22a5c0e 100644 --- a/drivers/spi/nxp_fspi.c +++ b/drivers/spi/nxp_fspi.c @@ -421,7 +421,7 @@ static bool nxp_fspi_supports_op(struct spi_slave *slave, return true; } -/* Instead of busy looping invoke readl_poll_timeout functionality. */ +/* Instead of busy looping invoke readl_poll_sleep_timeout functionality. */ static int fspi_readl_poll_tout(struct nxp_fspi *f, void __iomem *base, u32 mask, u32 delay_us, u32 timeout_us, bool c) @@ -432,11 +432,11 @@ static int fspi_readl_poll_tout(struct nxp_fspi *f, void __iomem *base, mask = (u32)cpu_to_be32(mask); if (c) - return readl_poll_timeout(base, reg, (reg & mask), - timeout_us); + return readl_poll_sleep_timeout(base, reg, (reg & mask), + delay_us, timeout_us); else - return readl_poll_timeout(base, reg, !(reg & mask), - timeout_us); + return readl_poll_sleep_timeout(base, reg, !(reg & mask), + delay_us, timeout_us); } /* diff --git a/include/clk.h b/include/clk.h index 60c4b7d..c6a2713 100644 --- a/include/clk.h +++ b/include/clk.h @@ -93,7 +93,7 @@ int clk_get_by_index_platdata(struct udevice *dev, int index, struct phandle_1_arg *cells, struct clk *clk); /** - * clock_get_by_index - Get/request a clock by integer index. + * clk_get_by_index - Get/request a clock by integer index. * * This looks up and requests a clock. The index is relative to the client * device; each device is assumed to have n clocks associated with it somehow, @@ -110,7 +110,7 @@ int clk_get_by_index_platdata(struct udevice *dev, int index, int clk_get_by_index(struct udevice *dev, int index, struct clk *clk); /** - * clock_get_by_index_nodev - Get/request a clock by integer index + * clk_get_by_index_nodev - Get/request a clock by integer index * without a device. * * This is a version of clk_get_by_index() that does not use a device. @@ -124,7 +124,7 @@ int clk_get_by_index(struct udevice *dev, int index, struct clk *clk); int clk_get_by_index_nodev(ofnode node, int index, struct clk *clk); /** - * clock_get_bulk - Get/request all clocks of a device. + * clk_get_bulk - Get/request all clocks of a device. * * This looks up and requests all clocks of the client device; each device is * assumed to have n clocks associated with it somehow, and this function finds @@ -139,7 +139,7 @@ int clk_get_by_index_nodev(ofnode node, int index, struct clk *clk); int clk_get_bulk(struct udevice *dev, struct clk_bulk *bulk); /** - * clock_get_by_name - Get/request a clock by name. + * clk_get_by_name - Get/request a clock by name. * * This looks up and requests a clock. The name is relative to the client * device; each device is assumed to have n clocks associated with it somehow, @@ -169,7 +169,7 @@ int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk); int clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk); /** - * clock_get_optional_nodev - Get/request an optinonal clock by name + * clk_get_optional_nodev - Get/request an optinonal clock by name * without a device. * @node: The client ofnode. * @name: The name of the clock to request. @@ -331,7 +331,7 @@ static inline int clk_release_bulk(struct clk_bulk *bulk) int clk_request(struct udevice *dev, struct clk *clk); /** - * clock_free - Free a previously requested clock. + * clk_free - Free a previously requested clock. * * @clock: A clock struct that was previously successfully requested by * clk_request/get_by_*(). diff --git a/include/configs/devkit3250.h b/include/configs/devkit3250.h index f1f2be0..4471a12 100644 --- a/include/configs/devkit3250.h +++ b/include/configs/devkit3250.h @@ -55,11 +55,6 @@ #define CONFIG_LPC32XX_GPIO /* - * SSP/SPI - */ -#define CONFIG_LPC32XX_SSP_TIMEOUT 100000 - -/* * Ethernet */ #define CONFIG_RMII diff --git a/include/configs/work_92105.h b/include/configs/work_92105.h index 421384d..93c8d64 100644 --- a/include/configs/work_92105.h +++ b/include/configs/work_92105.h @@ -105,11 +105,6 @@ #define CONFIG_LPC32XX_GPIO /* - * SSP/SPI/DISPLAY - */ - -#define CONFIG_LPC32XX_SSP_TIMEOUT 100000 -/* * Environment */ diff --git a/include/generic-phy.h b/include/generic-phy.h index 55629ae..5ab34cd 100644 --- a/include/generic-phy.h +++ b/include/generic-phy.h @@ -213,12 +213,15 @@ int generic_phy_get_by_index(struct udevice *user, int index, struct phy *phy); /** - * generic_phy_get_by_node() - Get a PHY device by integer index on ofnode + * generic_phy_get_by_index_nodev() - Get a PHY device by integer index + * without a device * - * @node: the device node + * @node: The client ofnode. * @index: The index in the list of available PHYs * @phy: A pointer to the PHY port * + * This is a version of generic_phy_get_by_index() that does not use a device. + * * This looks up a PHY device for a client device based on its ofnode and on * its position in the list of the possible PHYs. * @@ -237,7 +240,7 @@ int generic_phy_get_by_index(struct udevice *user, int index, * * @return 0 if OK, or a negative error code */ -int generic_phy_get_by_node(ofnode node, int index, struct phy *phy); +int generic_phy_get_by_index_nodev(ofnode node, int index, struct phy *phy); /** * generic_phy_get_by_name() - Get a PHY device by its name. diff --git a/include/linux/iopoll.h b/include/linux/iopoll.h index ab0ae19..30cdea0 100644 --- a/include/linux/iopoll.h +++ b/include/linux/iopoll.h @@ -6,16 +6,18 @@ #ifndef _LINUX_IOPOLL_H #define _LINUX_IOPOLL_H +#include <linux/delay.h> #include <linux/errno.h> #include <linux/io.h> #include <time.h> /** - * readx_poll_timeout - Periodically poll an address until a condition is met or a timeout occurs + * read_poll_timeout - Periodically poll an address until a condition is met or a timeout occurs * @op: accessor function (takes @addr as its only argument) * @addr: Address to poll * @val: Variable to read the value into * @cond: Break condition (usually involving @val) + * @sleep_us: Maximum time to sleep in us * @timeout_us: Timeout in us, 0 means never timeout * * Returns 0 on success and -ETIMEDOUT upon a timeout. In either @@ -24,7 +26,7 @@ * When available, you'll probably want to use one of the specialized * macros defined below rather than this macro directly. */ -#define readx_poll_timeout(op, addr, val, cond, timeout_us) \ +#define read_poll_timeout(op, addr, val, cond, sleep_us, timeout_us) \ ({ \ unsigned long timeout = timer_get_us() + timeout_us; \ for (;;) { \ @@ -35,10 +37,20 @@ (val) = op(addr); \ break; \ } \ + if (sleep_us) \ + udelay(sleep_us); \ } \ (cond) ? 0 : -ETIMEDOUT; \ }) +#define readx_poll_sleep_timeout(op, addr, val, cond, sleep_us, timeout_us) \ + read_poll_timeout(op, addr, val, cond, sleep_us, timeout_us) + +#define readl_poll_sleep_timeout(addr, val, cond, sleep_us, timeout_us) \ + readx_poll_sleep_timeout(readl, addr, val, cond, sleep_us, timeout_us) + +#define readx_poll_timeout(op, addr, val, cond, timeout_us) \ + read_poll_timeout(op, addr, val, cond, false, timeout_us) #define readb_poll_timeout(addr, val, cond, timeout_us) \ readx_poll_timeout(readb, addr, val, cond, timeout_us) diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index 741e954..253c461 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -1034,7 +1034,6 @@ CONFIG_LPC32XX_NAND_SLC_WDR_CLKS CONFIG_LPC32XX_NAND_SLC_WHOLD CONFIG_LPC32XX_NAND_SLC_WSETUP CONFIG_LPC32XX_NAND_SLC_WWIDTH -CONFIG_LPC32XX_SSP_TIMEOUT CONFIG_LPC_BASE CONFIG_LPC_IO_BASE CONFIG_LPUART |