- zap lpc32xx_ssp driver (Jagan)
- rename of phy nodev call (Jagan)
- iopoll with sleep_us (Jagan)
- MX25R6435F flash (Ye Li)
This commit is contained in:
Tom Rini
2020-05-11 08:27:55 -04:00
14 changed files with 47 additions and 179 deletions

View File

@@ -183,7 +183,8 @@ int board_usb_init(int index, enum usb_init_type init)
/* get the PHYs */ /* get the PHYs */
for (i = 0; i < 2; i++) { 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) { if (ret && ret != -ENOENT) {
pr_err("Failed to get USB PHY%d for %s\n", pr_err("Failed to get USB PHY%d for %s\n",
i, ofnode_get_name(dwc2_node)); i, ofnode_get_name(dwc2_node));

View File

@@ -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); ret = spi_nor_read_write_reg(nor, &op, val);
if (ret < 0) if (ret < 0)
dev_dbg(&flash->spimem->spi->dev, "error %d reading %x\n", ret, dev_dbg(nor->dev, "error %d reading %x\n", ret, code);
code);
return ret; return ret;
} }
@@ -1374,7 +1373,8 @@ static int spansion_read_cr_quad_enable(struct spi_nor *nor)
/* Check current Quad Enable bit value. */ /* Check current Quad Enable bit value. */
ret = read_cr(nor); ret = read_cr(nor);
if (ret < 0) { if (ret < 0) {
dev_dbg(dev, "error while reading configuration register\n"); dev_dbg(nor->dev,
"error while reading configuration register\n");
return -EINVAL; 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. */ /* Keep the current value of the Status Register. */
ret = read_sr(nor); ret = read_sr(nor);
if (ret < 0) { if (ret < 0) {
dev_dbg(dev, "error while reading status register\n"); dev_dbg(nor->dev, "error while reading status register\n");
return -EINVAL; return -EINVAL;
} }
sr_cr[0] = ret; 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), err = spi_nor_read_sfdp(nor, sizeof(header),
psize, param_headers); psize, param_headers);
if (err < 0) { 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; goto exit;
} }
} }
@@ -2099,7 +2100,8 @@ static int spi_nor_parse_sfdp(struct spi_nor *nor,
switch (SFDP_PARAM_HEADER_ID(param_header)) { switch (SFDP_PARAM_HEADER_ID(param_header)) {
case SFDP_SECTOR_MAP_ID: 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; break;
case SFDP_SST_ID: case SFDP_SST_ID:
@@ -2111,7 +2113,8 @@ static int spi_nor_parse_sfdp(struct spi_nor *nor,
} }
if (err) { 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)); SFDP_PARAM_HEADER_ID(param_header));
/* /*
* Let's not drop all information we extracted so far * 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) { 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); nor->addr_width);
return -EINVAL; return -EINVAL;
} }

View File

@@ -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("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("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("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 #endif
#ifdef CONFIG_SPI_FLASH_STMICRO /* STMICRO */ #ifdef CONFIG_SPI_FLASH_STMICRO /* STMICRO */

View File

@@ -32,7 +32,7 @@ static int generic_phy_xlate_offs_flags(struct phy *phy,
return 0; 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 ofnode_phandle_args args;
struct phy_ops *ops; struct phy_ops *ops;
@@ -94,7 +94,7 @@ err:
int generic_phy_get_by_index(struct udevice *dev, int index, int generic_phy_get_by_index(struct udevice *dev, int index,
struct phy *phy) 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, int generic_phy_get_by_name(struct udevice *dev, const char *phy_name,

View File

@@ -431,12 +431,6 @@ config KIRKWOOD_SPI
Enable support for SPI on various Marvell SoCs, such as Enable support for SPI on various Marvell SoCs, such as
Kirkwood and Armada 375. Kirkwood and Armada 375.
config LPC32XX_SSP
bool "LPC32XX SPI Driver"
depends on DEPRECATED
help
Enable support for SPI on LPC32xx
config MXC_SPI config MXC_SPI
bool "MXC SPI Driver" bool "MXC SPI Driver"
help help

View File

@@ -33,7 +33,6 @@ obj-$(CONFIG_FSL_ESPI) += fsl_espi.o
obj-$(CONFIG_FSL_QSPI) += fsl_qspi.o obj-$(CONFIG_FSL_QSPI) += fsl_qspi.o
obj-$(CONFIG_ICH_SPI) += ich.o obj-$(CONFIG_ICH_SPI) += ich.o
obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
obj-$(CONFIG_LPC32XX_SSP) += lpc32xx_ssp.o
obj-$(CONFIG_MESON_SPIFC) += meson_spifc.o obj-$(CONFIG_MESON_SPIFC) += meson_spifc.o
obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o
obj-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o obj-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o

View File

@@ -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 */
}

View File

@@ -421,7 +421,7 @@ static bool nxp_fspi_supports_op(struct spi_slave *slave,
return true; 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, static int fspi_readl_poll_tout(struct nxp_fspi *f, void __iomem *base,
u32 mask, u32 delay_us, u32 mask, u32 delay_us,
u32 timeout_us, bool c) 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); mask = (u32)cpu_to_be32(mask);
if (c) if (c)
return readl_poll_timeout(base, reg, (reg & mask), return readl_poll_sleep_timeout(base, reg, (reg & mask),
timeout_us); delay_us, timeout_us);
else else
return readl_poll_timeout(base, reg, !(reg & mask), return readl_poll_sleep_timeout(base, reg, !(reg & mask),
timeout_us); delay_us, timeout_us);
} }
/* /*

View File

@@ -93,7 +93,7 @@ int clk_get_by_index_platdata(struct udevice *dev, int index,
struct phandle_1_arg *cells, struct clk *clk); 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 * 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, * 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); 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. * without a device.
* *
* This is a version of clk_get_by_index() that does not use 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); 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 * 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 * 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); 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 * 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, * 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); 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. * without a device.
* @node: The client ofnode. * @node: The client ofnode.
* @name: The name of the clock to request. * @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); 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 * @clock: A clock struct that was previously successfully requested by
* clk_request/get_by_*(). * clk_request/get_by_*().

View File

@@ -54,11 +54,6 @@
*/ */
#define CONFIG_LPC32XX_GPIO #define CONFIG_LPC32XX_GPIO
/*
* SSP/SPI
*/
#define CONFIG_LPC32XX_SSP_TIMEOUT 100000
/* /*
* Ethernet * Ethernet
*/ */

View File

@@ -104,11 +104,6 @@
#define CONFIG_LPC32XX_GPIO #define CONFIG_LPC32XX_GPIO
/*
* SSP/SPI/DISPLAY
*/
#define CONFIG_LPC32XX_SSP_TIMEOUT 100000
/* /*
* Environment * Environment
*/ */

View File

@@ -213,12 +213,15 @@ int generic_phy_get_by_index(struct udevice *user, int index,
struct phy *phy); 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 * @index: The index in the list of available PHYs
* @phy: A pointer to the PHY port * @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 * 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. * 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 * @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. * generic_phy_get_by_name() - Get a PHY device by its name.

View File

@@ -6,16 +6,18 @@
#ifndef _LINUX_IOPOLL_H #ifndef _LINUX_IOPOLL_H
#define _LINUX_IOPOLL_H #define _LINUX_IOPOLL_H
#include <linux/delay.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/io.h> #include <linux/io.h>
#include <time.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) * @op: accessor function (takes @addr as its only argument)
* @addr: Address to poll * @addr: Address to poll
* @val: Variable to read the value into * @val: Variable to read the value into
* @cond: Break condition (usually involving @val) * @cond: Break condition (usually involving @val)
* @sleep_us: Maximum time to sleep in us
* @timeout_us: Timeout in us, 0 means never timeout * @timeout_us: Timeout in us, 0 means never timeout
* *
* Returns 0 on success and -ETIMEDOUT upon a timeout. In either * 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 * When available, you'll probably want to use one of the specialized
* macros defined below rather than this macro directly. * 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; \ unsigned long timeout = timer_get_us() + timeout_us; \
for (;;) { \ for (;;) { \
@@ -35,10 +37,20 @@
(val) = op(addr); \ (val) = op(addr); \
break; \ break; \
} \ } \
if (sleep_us) \
udelay(sleep_us); \
} \ } \
(cond) ? 0 : -ETIMEDOUT; \ (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) \ #define readb_poll_timeout(addr, val, cond, timeout_us) \
readx_poll_timeout(readb, addr, val, cond, timeout_us) readx_poll_timeout(readb, addr, val, cond, timeout_us)

View File

@@ -1034,7 +1034,6 @@ CONFIG_LPC32XX_NAND_SLC_WDR_CLKS
CONFIG_LPC32XX_NAND_SLC_WHOLD CONFIG_LPC32XX_NAND_SLC_WHOLD
CONFIG_LPC32XX_NAND_SLC_WSETUP CONFIG_LPC32XX_NAND_SLC_WSETUP
CONFIG_LPC32XX_NAND_SLC_WWIDTH CONFIG_LPC32XX_NAND_SLC_WWIDTH
CONFIG_LPC32XX_SSP_TIMEOUT
CONFIG_LPC_BASE CONFIG_LPC_BASE
CONFIG_LPC_IO_BASE CONFIG_LPC_IO_BASE
CONFIG_LPUART CONFIG_LPUART