mirror of https://github.com/hak5/openwrt-owl.git
ar71xx: remove a non-upstream spi core patch
- use standard flags instead - remove dead code from the rb4xx spi drivers Signed-off-by: Felix Fietkau <nbd@nbd.name>owl
parent
e3072599f6
commit
af79fdbe4a
|
@ -39,10 +39,5 @@ struct rb4xx_cpld_platform_data {
|
||||||
|
|
||||||
extern int rb4xx_cpld_change_cfg(unsigned mask, unsigned value);
|
extern int rb4xx_cpld_change_cfg(unsigned mask, unsigned value);
|
||||||
extern int rb4xx_cpld_read(unsigned char *rx_buf,
|
extern int rb4xx_cpld_read(unsigned char *rx_buf,
|
||||||
const unsigned char *verify_buf,
|
|
||||||
unsigned cnt);
|
unsigned cnt);
|
||||||
extern int rb4xx_cpld_read_from(unsigned addr,
|
|
||||||
unsigned char *rx_buf,
|
|
||||||
const unsigned char *verify_buf,
|
|
||||||
unsigned cnt);
|
|
||||||
extern int rb4xx_cpld_write(const unsigned char *buf, unsigned count);
|
extern int rb4xx_cpld_write(const unsigned char *buf, unsigned count);
|
||||||
|
|
|
@ -107,7 +107,7 @@ static unsigned char rb4xx_nand_read_byte(struct mtd_info *mtd)
|
||||||
unsigned char data = 0;
|
unsigned char data = 0;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = rb4xx_cpld_read(&data, NULL, 1);
|
err = rb4xx_cpld_read(&data, 1);
|
||||||
if (err) {
|
if (err) {
|
||||||
pr_err("rb4xx_nand: read data failed, err=%d\n", err);
|
pr_err("rb4xx_nand: read data failed, err=%d\n", err);
|
||||||
data = 0xff;
|
data = 0xff;
|
||||||
|
@ -131,7 +131,7 @@ static void rb4xx_nand_read_buf(struct mtd_info *mtd, unsigned char *buf,
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = rb4xx_cpld_read(buf, NULL, len);
|
err = rb4xx_cpld_read(buf, len);
|
||||||
if (err)
|
if (err)
|
||||||
pr_err("rb4xx_nand: read buf failed, err=%d\n", err);
|
pr_err("rb4xx_nand: read buf failed, err=%d\n", err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,73 +131,7 @@ int rb4xx_cpld_change_cfg(unsigned mask, unsigned value)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(rb4xx_cpld_change_cfg);
|
EXPORT_SYMBOL_GPL(rb4xx_cpld_change_cfg);
|
||||||
|
|
||||||
int rb4xx_cpld_read_from(unsigned addr, unsigned char *rx_buf,
|
int rb4xx_cpld_read(unsigned char *rx_buf, unsigned count)
|
||||||
const unsigned char *verify_buf, unsigned count)
|
|
||||||
{
|
|
||||||
const unsigned char cmd[5] = {
|
|
||||||
CPLD_CMD_READ_FAST,
|
|
||||||
(addr >> 16) & 0xff,
|
|
||||||
(addr >> 8) & 0xff,
|
|
||||||
addr & 0xff,
|
|
||||||
0
|
|
||||||
};
|
|
||||||
struct spi_transfer t[2] = {
|
|
||||||
{
|
|
||||||
.tx_buf = &cmd,
|
|
||||||
.len = 5,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.tx_buf = verify_buf,
|
|
||||||
.rx_buf = rx_buf,
|
|
||||||
.len = count,
|
|
||||||
.verify = (verify_buf != NULL),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
struct spi_message m;
|
|
||||||
|
|
||||||
if (rb4xx_cpld == NULL)
|
|
||||||
return -ENODEV;
|
|
||||||
|
|
||||||
spi_message_init(&m);
|
|
||||||
m.fast_read = 1;
|
|
||||||
spi_message_add_tail(&t[0], &m);
|
|
||||||
spi_message_add_tail(&t[1], &m);
|
|
||||||
return spi_sync(rb4xx_cpld->spi, &m);
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL_GPL(rb4xx_cpld_read_from);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
int rb4xx_cpld_read(unsigned char *buf, unsigned char *verify_buf,
|
|
||||||
unsigned count)
|
|
||||||
{
|
|
||||||
struct spi_transfer t[2];
|
|
||||||
struct spi_message m;
|
|
||||||
unsigned char cmd[2];
|
|
||||||
|
|
||||||
if (rb4xx_cpld == NULL)
|
|
||||||
return -ENODEV;
|
|
||||||
|
|
||||||
spi_message_init(&m);
|
|
||||||
memset(&t, 0, sizeof(t));
|
|
||||||
|
|
||||||
/* send command */
|
|
||||||
t[0].tx_buf = cmd;
|
|
||||||
t[0].len = sizeof(cmd);
|
|
||||||
spi_message_add_tail(&t[0], &m);
|
|
||||||
|
|
||||||
cmd[0] = CPLD_CMD_READ_NAND;
|
|
||||||
cmd[1] = 0;
|
|
||||||
|
|
||||||
/* read data */
|
|
||||||
t[1].rx_buf = buf;
|
|
||||||
t[1].len = count;
|
|
||||||
spi_message_add_tail(&t[1], &m);
|
|
||||||
|
|
||||||
return spi_sync(rb4xx_cpld->spi, &m);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
int rb4xx_cpld_read(unsigned char *rx_buf, const unsigned char *verify_buf,
|
|
||||||
unsigned count)
|
|
||||||
{
|
{
|
||||||
static const unsigned char cmd[2] = { CPLD_CMD_READ_NAND, 0 };
|
static const unsigned char cmd[2] = { CPLD_CMD_READ_NAND, 0 };
|
||||||
struct spi_transfer t[2] = {
|
struct spi_transfer t[2] = {
|
||||||
|
@ -205,10 +139,8 @@ int rb4xx_cpld_read(unsigned char *rx_buf, const unsigned char *verify_buf,
|
||||||
.tx_buf = &cmd,
|
.tx_buf = &cmd,
|
||||||
.len = 2,
|
.len = 2,
|
||||||
}, {
|
}, {
|
||||||
.tx_buf = verify_buf,
|
|
||||||
.rx_buf = rx_buf,
|
.rx_buf = rx_buf,
|
||||||
.len = count,
|
.len = count,
|
||||||
.verify = (verify_buf != NULL),
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
struct spi_message m;
|
struct spi_message m;
|
||||||
|
@ -221,40 +153,10 @@ int rb4xx_cpld_read(unsigned char *rx_buf, const unsigned char *verify_buf,
|
||||||
spi_message_add_tail(&t[1], &m);
|
spi_message_add_tail(&t[1], &m);
|
||||||
return spi_sync(rb4xx_cpld->spi, &m);
|
return spi_sync(rb4xx_cpld->spi, &m);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
EXPORT_SYMBOL_GPL(rb4xx_cpld_read);
|
EXPORT_SYMBOL_GPL(rb4xx_cpld_read);
|
||||||
|
|
||||||
int rb4xx_cpld_write(const unsigned char *buf, unsigned count)
|
int rb4xx_cpld_write(const unsigned char *buf, unsigned count)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
struct spi_transfer t[3];
|
|
||||||
struct spi_message m;
|
|
||||||
unsigned char cmd[1];
|
|
||||||
|
|
||||||
if (rb4xx_cpld == NULL)
|
|
||||||
return -ENODEV;
|
|
||||||
|
|
||||||
memset(&t, 0, sizeof(t));
|
|
||||||
spi_message_init(&m);
|
|
||||||
|
|
||||||
/* send command */
|
|
||||||
t[0].tx_buf = cmd;
|
|
||||||
t[0].len = sizeof(cmd);
|
|
||||||
spi_message_add_tail(&t[0], &m);
|
|
||||||
|
|
||||||
cmd[0] = CPLD_CMD_WRITE_NAND;
|
|
||||||
|
|
||||||
/* write data */
|
|
||||||
t[1].tx_buf = buf;
|
|
||||||
t[1].len = count;
|
|
||||||
spi_message_add_tail(&t[1], &m);
|
|
||||||
|
|
||||||
/* send idle */
|
|
||||||
t[2].len = 1;
|
|
||||||
spi_message_add_tail(&t[2], &m);
|
|
||||||
|
|
||||||
return spi_sync(rb4xx_cpld->spi, &m);
|
|
||||||
#else
|
|
||||||
static const unsigned char cmd = CPLD_CMD_WRITE_NAND;
|
static const unsigned char cmd = CPLD_CMD_WRITE_NAND;
|
||||||
struct spi_transfer t[3] = {
|
struct spi_transfer t[3] = {
|
||||||
{
|
{
|
||||||
|
@ -263,10 +165,10 @@ int rb4xx_cpld_write(const unsigned char *buf, unsigned count)
|
||||||
}, {
|
}, {
|
||||||
.tx_buf = buf,
|
.tx_buf = buf,
|
||||||
.len = count,
|
.len = count,
|
||||||
.fast_write = 1,
|
.tx_nbits = SPI_NBITS_DUAL,
|
||||||
}, {
|
}, {
|
||||||
.len = 1,
|
.len = 1,
|
||||||
.fast_write = 1,
|
.tx_nbits = SPI_NBITS_DUAL,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
struct spi_message m;
|
struct spi_message m;
|
||||||
|
@ -279,7 +181,6 @@ int rb4xx_cpld_write(const unsigned char *buf, unsigned count)
|
||||||
spi_message_add_tail(&t[1], &m);
|
spi_message_add_tail(&t[1], &m);
|
||||||
spi_message_add_tail(&t[2], &m);
|
spi_message_add_tail(&t[2], &m);
|
||||||
return spi_sync(rb4xx_cpld->spi, &m);
|
return spi_sync(rb4xx_cpld->spi, &m);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(rb4xx_cpld_write);
|
EXPORT_SYMBOL_GPL(rb4xx_cpld_write);
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,6 @@ static void do_spi_byte_fast(void __iomem *base, unsigned char byte)
|
||||||
|
|
||||||
static int rb4xx_spi_txrx(void __iomem *base, struct spi_transfer *t)
|
static int rb4xx_spi_txrx(void __iomem *base, struct spi_transfer *t)
|
||||||
{
|
{
|
||||||
const unsigned char *rxv_ptr = NULL;
|
|
||||||
const unsigned char *tx_ptr = t->tx_buf;
|
const unsigned char *tx_ptr = t->tx_buf;
|
||||||
unsigned char *rx_ptr = t->rx_buf;
|
unsigned char *rx_ptr = t->rx_buf;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
@ -145,94 +144,21 @@ static int rb4xx_spi_txrx(void __iomem *base, struct spi_transfer *t)
|
||||||
(t->tx_buf ? 1 : 0),
|
(t->tx_buf ? 1 : 0),
|
||||||
(t->rx_buf ? 1 : 0));
|
(t->rx_buf ? 1 : 0));
|
||||||
|
|
||||||
if (t->verify) {
|
|
||||||
rxv_ptr = tx_ptr;
|
|
||||||
tx_ptr = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < t->len; ++i) {
|
for (i = 0; i < t->len; ++i) {
|
||||||
unsigned char sdata = tx_ptr ? tx_ptr[i] : 0;
|
unsigned char sdata = tx_ptr ? tx_ptr[i] : 0;
|
||||||
|
|
||||||
if (t->fast_write)
|
if (t->tx_nbits == SPI_NBITS_DUAL)
|
||||||
do_spi_byte_fast(base, sdata);
|
do_spi_byte_fast(base, sdata);
|
||||||
else
|
else
|
||||||
do_spi_byte(base, sdata);
|
do_spi_byte(base, sdata);
|
||||||
|
|
||||||
if (rx_ptr) {
|
if (rx_ptr)
|
||||||
rx_ptr[i] = __raw_readl(base + AR71XX_SPI_REG_RDS) & 0xff;
|
rx_ptr[i] = __raw_readl(base + AR71XX_SPI_REG_RDS) & 0xff;
|
||||||
} else if (rxv_ptr) {
|
|
||||||
unsigned char c = __raw_readl(base + AR71XX_SPI_REG_RDS);
|
|
||||||
if (rxv_ptr[i] != c)
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rb4xx_spi_read_fast(struct rb4xx_spi *rbspi,
|
|
||||||
struct spi_message *m)
|
|
||||||
{
|
|
||||||
struct spi_transfer *t;
|
|
||||||
const unsigned char *tx_ptr;
|
|
||||||
unsigned addr;
|
|
||||||
void __iomem *base = rbspi->base;
|
|
||||||
|
|
||||||
/* check for exactly two transfers */
|
|
||||||
if (list_empty(&m->transfers) ||
|
|
||||||
list_is_last(m->transfers.next, &m->transfers) ||
|
|
||||||
!list_is_last(m->transfers.next->next, &m->transfers)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* first transfer contains command and address */
|
|
||||||
t = list_entry(m->transfers.next,
|
|
||||||
struct spi_transfer, transfer_list);
|
|
||||||
|
|
||||||
if (t->len != 5 || t->tx_buf == NULL)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
tx_ptr = t->tx_buf;
|
|
||||||
if (tx_ptr[0] != CPLD_CMD_READ_FAST)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
addr = tx_ptr[1];
|
|
||||||
addr = tx_ptr[2] | (addr << 8);
|
|
||||||
addr = tx_ptr[3] | (addr << 8);
|
|
||||||
addr += (unsigned) base;
|
|
||||||
|
|
||||||
m->actual_length += t->len;
|
|
||||||
|
|
||||||
/* second transfer contains data itself */
|
|
||||||
t = list_entry(m->transfers.next->next,
|
|
||||||
struct spi_transfer, transfer_list);
|
|
||||||
|
|
||||||
if (t->tx_buf && !t->verify)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
__raw_writel(AR71XX_SPI_FS_GPIO, base + AR71XX_SPI_REG_FS);
|
|
||||||
__raw_writel(rbspi->spi_ctrl_fread, base + AR71XX_SPI_REG_CTRL);
|
|
||||||
__raw_writel(0, base + AR71XX_SPI_REG_FS);
|
|
||||||
|
|
||||||
if (t->rx_buf) {
|
|
||||||
memcpy(t->rx_buf, (const void *)addr, t->len);
|
|
||||||
} else if (t->tx_buf) {
|
|
||||||
unsigned char buf[t->len];
|
|
||||||
memcpy(buf, (const void *)addr, t->len);
|
|
||||||
if (memcmp(t->tx_buf, buf, t->len) != 0)
|
|
||||||
m->status = -EMSGSIZE;
|
|
||||||
}
|
|
||||||
m->actual_length += t->len;
|
|
||||||
|
|
||||||
if (rbspi->spi_ctrl_flash != rbspi->spi_ctrl_fread) {
|
|
||||||
__raw_writel(AR71XX_SPI_FS_GPIO, base + AR71XX_SPI_REG_FS);
|
|
||||||
__raw_writel(rbspi->spi_ctrl_flash, base + AR71XX_SPI_REG_CTRL);
|
|
||||||
__raw_writel(0, base + AR71XX_SPI_REG_FS);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int rb4xx_spi_msg(struct rb4xx_spi *rbspi, struct spi_message *m)
|
static int rb4xx_spi_msg(struct rb4xx_spi *rbspi, struct spi_message *m)
|
||||||
{
|
{
|
||||||
struct spi_transfer *t = NULL;
|
struct spi_transfer *t = NULL;
|
||||||
|
@ -242,10 +168,6 @@ static int rb4xx_spi_msg(struct rb4xx_spi *rbspi, struct spi_message *m)
|
||||||
if (list_empty(&m->transfers))
|
if (list_empty(&m->transfers))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (m->fast_read)
|
|
||||||
if (rb4xx_spi_read_fast(rbspi, m) == 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
__raw_writel(AR71XX_SPI_FS_GPIO, base + AR71XX_SPI_REG_FS);
|
__raw_writel(AR71XX_SPI_FS_GPIO, base + AR71XX_SPI_REG_FS);
|
||||||
__raw_writel(SPI_CTRL_FASTEST, base + AR71XX_SPI_REG_CTRL);
|
__raw_writel(SPI_CTRL_FASTEST, base + AR71XX_SPI_REG_CTRL);
|
||||||
do_spi_init(m->spi);
|
do_spi_init(m->spi);
|
||||||
|
@ -402,6 +324,7 @@ static int rb4xx_spi_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
master->bus_num = 0;
|
master->bus_num = 0;
|
||||||
master->num_chipselect = 3;
|
master->num_chipselect = 3;
|
||||||
|
master->mode_bits = SPI_TX_DUAL;
|
||||||
master->setup = rb4xx_spi_setup;
|
master->setup = rb4xx_spi_setup;
|
||||||
master->transfer = rb4xx_spi_transfer;
|
master->transfer = rb4xx_spi_transfer;
|
||||||
|
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
--- a/include/linux/spi/spi.h
|
|
||||||
+++ b/include/linux/spi/spi.h
|
|
||||||
@@ -695,6 +695,8 @@ struct spi_transfer {
|
|
||||||
unsigned cs_change:1;
|
|
||||||
unsigned tx_nbits:3;
|
|
||||||
unsigned rx_nbits:3;
|
|
||||||
+ unsigned verify:1;
|
|
||||||
+ unsigned fast_write:1;
|
|
||||||
#define SPI_NBITS_SINGLE 0x01 /* 1bit transfer */
|
|
||||||
#define SPI_NBITS_DUAL 0x02 /* 2bits transfer */
|
|
||||||
#define SPI_NBITS_QUAD 0x04 /* 4bits transfer */
|
|
||||||
@@ -740,6 +742,7 @@ struct spi_message {
|
|
||||||
struct spi_device *spi;
|
|
||||||
|
|
||||||
unsigned is_dma_mapped:1;
|
|
||||||
+ unsigned fast_read:1;
|
|
||||||
|
|
||||||
/* REVISIT: we might want a flag affecting the behavior of the
|
|
||||||
* last transfer ... allowing things like "read 16 bit length L"
|
|
Loading…
Reference in New Issue