summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Sliwa <dominik.sliwa@toradex.com>2018-02-01 12:52:56 +0100
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2018-03-28 18:30:30 +0200
commite2479101d95625c1c2fcb7c8f72fe515d9099cc1 (patch)
tree5291e1c38bbbf97605c054caeea8d7ed29c40eaa
parente57a938d023cdf933731a77a350cfacadc37d3c4 (diff)
mfd: apalis-tk1-k20: single transaction register read
This change also modifies SPI clock for ezPort mode. Signed-off-by: Dominik Sliwa <dominik.sliwa@toradex.com> Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
-rw-r--r--arch/arm/boot/dts/tegra124-apalis-v1.2-eval.dts2
-rw-r--r--drivers/mfd/apalis-tk1-k20-ezp.h2
-rw-r--r--drivers/mfd/apalis-tk1-k20.c93
-rw-r--r--drivers/net/can/apalis-tk1-k20-can.c10
4 files changed, 16 insertions, 91 deletions
diff --git a/arch/arm/boot/dts/tegra124-apalis-v1.2-eval.dts b/arch/arm/boot/dts/tegra124-apalis-v1.2-eval.dts
index 95f68ba532ed..941428269903 100644
--- a/arch/arm/boot/dts/tegra124-apalis-v1.2-eval.dts
+++ b/arch/arm/boot/dts/tegra124-apalis-v1.2-eval.dts
@@ -174,7 +174,7 @@
spidev2: spidev@2 {
compatible = "spidev";
reg = <2>;
- spi-max-frequency = <3000000>;
+ spi-max-frequency = <3500000>;
};
};
diff --git a/drivers/mfd/apalis-tk1-k20-ezp.h b/drivers/mfd/apalis-tk1-k20-ezp.h
index 92ab497dd5c7..922d55dcfe16 100644
--- a/drivers/mfd/apalis-tk1-k20-ezp.h
+++ b/drivers/mfd/apalis-tk1-k20-ezp.h
@@ -37,7 +37,7 @@
#define APALIS_TK1_K20_EZP_STA_WEF BIT(6)
#define APALIS_TK1_K20_EZP_STA_FS BIT(7)
-#define APALIS_TK1_K20_EZP_MAX_SPEED 3000000
+#define APALIS_TK1_K20_EZP_MAX_SPEED 3500000
#define APALIS_TK1_K20_EZP_MAX_DATA 32
#define APALIS_TK1_K20_EZP_WRITE_SIZE 32
diff --git a/drivers/mfd/apalis-tk1-k20.c b/drivers/mfd/apalis-tk1-k20.c
index 84774538eb44..1ab5542af0d1 100644
--- a/drivers/mfd/apalis-tk1-k20.c
+++ b/drivers/mfd/apalis-tk1-k20.c
@@ -67,23 +67,19 @@ static int apalis_tk1_k20_spi_read(void *context, const void *reg,
size_t reg_size, void *val, size_t val_size)
{
unsigned char w[APALIS_TK1_K20_MAX_BULK] = {APALIS_TK1_K20_READ_INST,
- val_size, *((unsigned char *) reg)};
+ *((unsigned char *) reg), val_size, 0x00, 0x00};
+ unsigned char r[APALIS_TK1_K20_MAX_BULK];
unsigned char *p = val;
struct device *dev = context;
struct spi_device *spi = to_spi_device(dev);
struct spi_transfer t = {
.tx_buf = w,
- .rx_buf = NULL,
- .len = 3,
+ .rx_buf = r,
+ .len = 6,
.cs_change = 0,
.delay_usecs = 0,
};
-#ifdef CONFIG_EXPERIMENTAL_K20_HSMODE
- struct spi_transfer ts[APALIS_TK1_K20_MAX_BULK /
- APALIS_TK1_K20_MAX_MSG];
- int i = 0;
- int transfer_count;
-#endif
+
struct spi_message m;
int ret;
spi->mode = SPI_MODE_1;
@@ -95,14 +91,11 @@ static int apalis_tk1_k20_spi_read(void *context, const void *reg,
spi_message_init(&m);
spi_message_add_tail(&t, &m);
ret = spi_sync(spi, &m);
- /* no need to reinit the message*/
- t.len = 1;
- t.rx_buf = p;
- /* just use the same transfer */
- ret = spi_sync(spi, &m);
+ *p = ((unsigned char *)t.rx_buf)[5];
#ifdef CONFIG_V12_K20_HSMODE
} else if ((val_size > 1) && (val_size < APALIS_TK1_K20_MAX_BULK)) {
+ t.len = 3;
w[0] = APALIS_TK1_K20_BULK_READ_INST;
spi_message_init(&m);
spi_message_add_tail(&t, &m);
@@ -117,37 +110,7 @@ static int apalis_tk1_k20_spi_read(void *context, const void *reg,
} else {
return -ENOTSUPP;
}
-#if 0
- if (r[0] == TK1_K20_SENTINEL)
- memcpy(p, &r[1], val_size);
- else {
- if (r[0] != TK1_K20_INVAL) {
- dev_err(dev, "K20 FIFO Bug!");
- /* we've probably hit the K20 FIFO bug, try to resync */
- spi_message_init(&m);
- w[0] = APALIS_TK1_K20_READ_INST;
- w[1] = 0x01;
- w[2] = APALIS_TK1_K20_RET_REQ;
- w[3] = 0x00;
- t.tx_buf = w;
- t.len = 4;
- spi_message_add_tail(&t, &m);
- ret = spi_sync(spi, &m);
- spi_message_init(&m);
- t.len = val_size + 1;
- spi_message_add_tail(&t, &m);
- /* Give k20 some time to recover */
- udelay(2000);
- ret = spi_sync(spi, &m);
-
- if (r[0] == TK1_K20_SENTINEL) {
- memcpy(p, &r[1], val_size);
- return ret;
- }
- }
- return -EIO;
- }
-#endif
+
return ret;
}
@@ -159,19 +122,7 @@ static int apalis_tk1_k20_spi_write(void *context, const void *data,
struct spi_device *spi = to_spi_device(dev);
uint8_t out_data[APALIS_TK1_K20_MAX_BULK];
int ret;
-#ifdef CONFIG_EXPERIMENTAL_K20_HSMODE
- uint8_t in_data[APALIS_TK1_K20_MAX_BULK];
- struct spi_message m;
- struct spi_transfer t = {
- .tx_buf = out_data,
- .rx_buf = in_data,
- .cs_change = 0,
- .delay_usecs = 0,
- };
- struct spi_transfer ts[(APALIS_TK1_K20_MAX_BULK /
- APALIS_TK1_K20_MAX_MSG) + 1];
- int i = 0;
-#endif
+
spi->mode = SPI_MODE_1;
@@ -188,32 +139,6 @@ static int apalis_tk1_k20_spi_write(void *context, const void *data,
memcpy(&out_data[2], data, count);
ret = spi_write(spi, out_data, count + 2);
#endif
-#ifdef CONFIG_EXPERIMENTAL_K20_HSMODE
- } else if ((count > 2) && (count < APALIS_TK1_K20_MAX_BULK)) {
-
- spi_message_init(&m);
- out_data[0] = APALIS_TK1_K20_BULK_WRITE_INST;
- out_data[1] = count - 1;
- memcpy(&out_data[2], data, count);
- t.tx_buf = out_data;
- t.len = 4;
- spi_message_add_tail(&t, &m);
- ret = spi_sync(spi, &m);
- /* reg. addr + 2 data bytes */
- count = count - 3;
-
- spi_message_init(&m);
- for (i = 0; count > 0; i++) {
- ts[i].tx_buf = &out_data[(i + 1) * 4];
- ts[i].len = (count >= 4) ? 4 : count;
- ts[i].cs_change = 0;
- ts[i].delay_usecs = 0;
-
- spi_message_add_tail(&ts[i], &m);
- count = count - ts[i].len;
- }
- ret = spi_sync(spi, &m);
-#endif
} else {
dev_err(dev, "Apalis TK1 K20 MFD invalid write count = %d\n",
count);
diff --git a/drivers/net/can/apalis-tk1-k20-can.c b/drivers/net/can/apalis-tk1-k20-can.c
index 5d0f5d764ceb..c32a70181ac1 100644
--- a/drivers/net/can/apalis-tk1-k20-can.c
+++ b/drivers/net/can/apalis-tk1-k20-can.c
@@ -168,14 +168,14 @@ static void apalis_tk1_k20_can_hw_rx(struct net_device *net, int buf_idx)
return;
}
- apalis_tk1_k20_can_hw_rx_frame(net, (unsigned char *)frame, buf_idx);
+ apalis_tk1_k20_can_hw_rx_frame(net, (unsigned char *)frame, buf_idx);
- priv->net->stats.rx_packets++;
- priv->net->stats.rx_bytes += frame->can_dlc;
+ priv->net->stats.rx_packets++;
+ priv->net->stats.rx_bytes += frame->can_dlc;
- can_led_event(priv->net, CAN_LED_EVENT_RX);
+ can_led_event(priv->net, CAN_LED_EVENT_RX);
- netif_rx_ni(skb);
+ netif_rx_ni(skb);
}