summaryrefslogtreecommitdiffstats
path: root/recipes-kernel
diff options
context:
space:
mode:
authorKoen Kooi <koen@dominion.thruhere.net>2012-02-09 20:21:23 +0100
committerDenys Dmytriyenko <denys@ti.com>2012-02-10 21:32:46 -0500
commit2405c4176760e9659d1748362a83ce07d650e495 (patch)
tree3a2e4409b93d7de7c6cea94a55d82b6ea0624838 /recipes-kernel
parent80f44e2127e41831b7566b56d811bf034ce00623 (diff)
downloadmeta-ti-2405c4176760e9659d1748362a83ce07d650e495.tar.gz
linux-ti33x-psp 3.2: add support for Towertech TT3201 CAN cape
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net> Signed-off-by: Denys Dmytriyenko <denys@ti.com>
Diffstat (limited to 'recipes-kernel')
-rw-r--r--recipes-kernel/linux/linux-ti33x-psp-3.2/0022-beaglebone-add-support-for-Towertech-TT3201-CAN-cape.patch312
-rw-r--r--recipes-kernel/linux/linux-ti33x-psp-3.2/beaglebone/defconfig14
-rw-r--r--recipes-kernel/linux/linux-ti33x-psp_3.2.bb3
3 files changed, 321 insertions, 8 deletions
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.2/0022-beaglebone-add-support-for-Towertech-TT3201-CAN-cape.patch b/recipes-kernel/linux/linux-ti33x-psp-3.2/0022-beaglebone-add-support-for-Towertech-TT3201-CAN-cape.patch
new file mode 100644
index 00000000..086ace97
--- /dev/null
+++ b/recipes-kernel/linux/linux-ti33x-psp-3.2/0022-beaglebone-add-support-for-Towertech-TT3201-CAN-cape.patch
@@ -0,0 +1,312 @@
1From af31b4d5a2d52284b169633b9a601c39c7300300 Mon Sep 17 00:00:00 2001
2From: Alessandro Zummo <a.zummo@towertech.it>
3Date: Thu, 9 Feb 2012 12:46:52 +0100
4Subject: [PATCH 22/22] beaglebone: add support for Towertech TT3201 CAN cape
5
6Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
7---
8 arch/arm/mach-omap2/board-am335xevm.c | 54 ++++++++++++++++++++++++++++++++-
9 arch/arm/mach-omap2/mux33xx.c | 4 +-
10 drivers/net/can/dev.c | 8 ++--
11 drivers/net/can/mcp251x.c | 47 ++++++++++++++++++++++------
12 4 files changed, 96 insertions(+), 17 deletions(-)
13
14diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
15index 538466d..36efca1 100644
16--- a/arch/arm/mach-omap2/board-am335xevm.c
17+++ b/arch/arm/mach-omap2/board-am335xevm.c
18@@ -38,6 +38,7 @@
19 #include <linux/pwm_backlight.h>
20 #include <linux/pwm/pwm.h>
21 #include <linux/w1-gpio.h>
22+#include <linux/can/platform/mcp251x.h>
23
24 /* LCD controller is similar to DA850 */
25 #include <video/da8xx-fb.h>
26@@ -829,6 +830,15 @@ static struct pinmux_config d_can_ia_pin_mux[] = {
27 {NULL, 0},
28 };
29
30+static struct pinmux_config tt3201_pin_mux[] = {
31+ {"uart1_rxd.d_can1_tx", OMAP_MUX_MODE2 | AM33XX_PIN_OUTPUT },
32+ {"uart1_txd.d_can1_rx", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLUP },
33+ {"mcasp0_fsr.gpio3_19", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT_PULLUP },
34+ {"mcasp0_ahclkx.gpio3_21", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT_PULLUP },
35+ {"ecap0_in_pwm0_out.spi1_cs1", OMAP_MUX_MODE2 | AM33XX_PIN_OUTPUT_PULLUP },
36+ {NULL, 0},
37+};
38+
39 /* Module pin mux for uart2 */
40 static struct pinmux_config uart2_pin_mux[] = {
41 {"spi0_sclk.uart2_rxd", OMAP_MUX_MODE1 | AM33XX_SLEWCTRL_SLOW |
42@@ -1788,6 +1798,44 @@ static void i2c1_init(int evm_id, int profile)
43 return;
44 }
45
46+static struct mcp251x_platform_data mcp251x_info = {
47+ .oscillator_frequency = 16000000,
48+};
49+
50+static struct spi_board_info tt3201_spi_info[] = {
51+ {
52+ .modalias = "mcp2515",
53+ .max_speed_hz = 10000000,
54+ .bus_num = 2,
55+ .chip_select = 0,
56+ .mode = SPI_MODE_0,
57+ .platform_data = &mcp251x_info,
58+ },
59+ {
60+ .modalias = "mcp2515",
61+ .max_speed_hz = 10000000,
62+ .bus_num = 2,
63+ .chip_select = 1,
64+ .mode = SPI_MODE_0,
65+ .platform_data = &mcp251x_info,
66+ },
67+};
68+
69+static void tt3201_init(int evm_id, int profile)
70+{
71+ pr_info("TowerTech TT3201 CAN Cape\n");
72+
73+ setup_pin_mux(spi1_pin_mux);
74+ setup_pin_mux(tt3201_pin_mux);
75+
76+ tt3201_spi_info[0].irq = gpio_to_irq(GPIO_TO_PIN(3, 19));
77+ tt3201_spi_info[1].irq = gpio_to_irq(GPIO_TO_PIN(3, 21));
78+
79+ spi_register_board_info(tt3201_spi_info,
80+ ARRAY_SIZE(tt3201_spi_info));
81+
82+ am33xx_d_can_init(1);
83+}
84 static void beaglebone_cape_setup(struct memory_accessor *mem_acc, void *context)
85 {
86 capecount++;
87@@ -1835,7 +1883,11 @@ static void beaglebone_cape_setup(struct memory_accessor *mem_acc, void *context
88 beaglebone_tsadcpins_free = 0;
89 }
90
91-
92+ if (!strncmp("TT3201-001", cape_config.partnumber, 10)) {
93+ pr_info("BeagleBone cape: initializing CAN cape\n");
94+ tt3201_init(0,0);
95+ }
96+
97 if ((capecount > 3) && (beaglebone_tsadcpins_free == 1)) {
98 pr_info("BeagleBone cape: exporting ADC pins to sysfs\n");
99 bone_tsc_init(0,0);
100diff --git a/arch/arm/mach-omap2/mux33xx.c b/arch/arm/mach-omap2/mux33xx.c
101index 0a06241..e4f3bd9 100644
102--- a/arch/arm/mach-omap2/mux33xx.c
103+++ b/arch/arm/mach-omap2/mux33xx.c
104@@ -318,10 +318,10 @@ static struct omap_mux __initdata am33xx_muxmodes[] = {
105 "uart1_rtsn", NULL, "d_can0_rx", "i2c2_scl",
106 "spi1_cs1", NULL, NULL, "gpio0_13"),
107 _AM33XX_MUXENTRY(UART1_RXD, 0,
108- "uart1_rxd", "mmc1_sdwp", NULL, NULL,
109+ "uart1_rxd", "mmc1_sdwp", "d_can1_tx", NULL,
110 NULL, "pr1_uart0_rxd_mux1", NULL, "gpio0_14"),
111 _AM33XX_MUXENTRY(UART1_TXD, 0,
112- "uart1_txd", "mmc2_sdwp", NULL, NULL,
113+ "uart1_txd", "mmc2_sdwp", "d_can1_rx", NULL,
114 NULL, "pr1_uart0_txd_mux1", NULL, "gpio0_15"),
115 _AM33XX_MUXENTRY(I2C0_SDA, 0,
116 "i2c0_sda", NULL, NULL, NULL,
117diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
118index 25695bd..bc1e87e 100644
119--- a/drivers/net/can/dev.c
120+++ b/drivers/net/can/dev.c
121@@ -392,7 +392,7 @@ void can_restart(unsigned long data)
122 stats->rx_bytes += cf->can_dlc;
123
124 restart:
125- dev_dbg(dev->dev.parent, "restarted\n");
126+ netdev_dbg(dev, "restarted\n");
127 priv->can_stats.restarts++;
128
129 /* Now restart the device */
130@@ -400,7 +400,7 @@ restart:
131
132 netif_carrier_on(dev);
133 if (err)
134- dev_err(dev->dev.parent, "Error %d during restart", err);
135+ netdev_err(dev, "error %d during restart", err);
136 }
137
138 int can_restart_now(struct net_device *dev)
139@@ -433,7 +433,7 @@ void can_bus_off(struct net_device *dev)
140 {
141 struct can_priv *priv = netdev_priv(dev);
142
143- dev_dbg(dev->dev.parent, "bus-off\n");
144+ netdev_dbg(dev, "bus-off\n");
145
146 netif_carrier_off(dev);
147 priv->can_stats.bus_off++;
148@@ -545,7 +545,7 @@ int open_candev(struct net_device *dev)
149 struct can_priv *priv = netdev_priv(dev);
150
151 if (!priv->bittiming.tq && !priv->bittiming.bitrate) {
152- dev_err(dev->dev.parent, "bit-timing not yet defined\n");
153+ netdev_err(dev, "bit-timing not yet defined\n");
154 return -EINVAL;
155 }
156
157diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
158index 330140e..b3e231c 100644
159--- a/drivers/net/can/mcp251x.c
160+++ b/drivers/net/can/mcp251x.c
161@@ -93,8 +93,9 @@
162 # define CANCTRL_REQOP_LOOPBACK 0x40
163 # define CANCTRL_REQOP_SLEEP 0x20
164 # define CANCTRL_REQOP_NORMAL 0x00
165-# define CANCTRL_OSM 0x08
166 # define CANCTRL_ABAT 0x10
167+# define CANCTRL_OSM 0x08
168+# define CANCTRL_CLKEN 0x04
169 #define TEC 0x1c
170 #define REC 0x1d
171 #define CNF1 0x2a
172@@ -287,7 +288,7 @@ static void mcp251x_clean(struct net_device *net)
173 /*
174 * Note about handling of error return of mcp251x_spi_trans: accessing
175 * registers via SPI is not really different conceptually than using
176- * normal I/O assembler instructions, although it's much more
177+ * normal I/O assembly instructions, although it's much more
178 * complicated from a practical POV. So it's not advisable to always
179 * check the return value of this function. Imagine that every
180 * read{b,l}, write{b,l} and friends would be bracketed in "if ( < 0)
181@@ -490,7 +491,7 @@ static void mcp251x_hw_rx(struct spi_device *spi, int buf_idx)
182
183 static void mcp251x_hw_sleep(struct spi_device *spi)
184 {
185- mcp251x_write_reg(spi, CANCTRL, CANCTRL_REQOP_SLEEP);
186+// mcp251x_write_reg(spi, CANCTRL, CANCTRL_REQOP_SLEEP);
187 }
188
189 static netdev_tx_t mcp251x_hard_start_xmit(struct sk_buff *skb,
190@@ -547,13 +548,16 @@ static int mcp251x_set_normal_mode(struct spi_device *spi)
191
192 if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK) {
193 /* Put device into loopback mode */
194- mcp251x_write_reg(spi, CANCTRL, CANCTRL_REQOP_LOOPBACK);
195+ mcp251x_write_reg(spi, CANCTRL, CANCTRL_REQOP_LOOPBACK | CANCTRL_CLKEN);
196 } else if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) {
197 /* Put device into listen-only mode */
198- mcp251x_write_reg(spi, CANCTRL, CANCTRL_REQOP_LISTEN_ONLY);
199+ mcp251x_write_reg(spi, CANCTRL, CANCTRL_REQOP_LISTEN_ONLY | CANCTRL_CLKEN);
200 } else {
201 /* Put device into normal mode */
202- mcp251x_write_reg(spi, CANCTRL, CANCTRL_REQOP_NORMAL);
203+ mcp251x_write_reg(spi, CANCTRL, CANCTRL_REQOP_NORMAL | CANCTRL_CLKEN);
204+
205+ netdev_info(priv->net, "CANCTRL: 0x%02x\n",
206+ mcp251x_read_reg(spi, CANCTRL));
207
208 /* Wait for the device to enter normal mode */
209 timeout = jiffies + HZ;
210@@ -585,11 +589,15 @@ static int mcp251x_do_set_bittiming(struct net_device *net)
211 (bt->prop_seg - 1));
212 mcp251x_write_bits(spi, CNF3, CNF3_PHSEG2_MASK,
213 (bt->phase_seg2 - 1));
214- dev_info(&spi->dev, "CNF: 0x%02x 0x%02x 0x%02x\n",
215+
216+ netdev_info(net, "CNF: 0x%02x 0x%02x 0x%02x\n",
217 mcp251x_read_reg(spi, CNF1),
218 mcp251x_read_reg(spi, CNF2),
219 mcp251x_read_reg(spi, CNF3));
220
221+ netdev_info(net, "CANCTRL: 0x%02x\n",
222+ mcp251x_read_reg(spi, CANCTRL));
223+
224 return 0;
225 }
226
227@@ -600,6 +608,7 @@ static int mcp251x_setup(struct net_device *net, struct mcp251x_priv *priv,
228
229 mcp251x_write_reg(spi, RXBCTRL(0),
230 RXBCTRL_BUKT | RXBCTRL_RXM0 | RXBCTRL_RXM1);
231+
232 mcp251x_write_reg(spi, RXBCTRL(1),
233 RXBCTRL_RXM0 | RXBCTRL_RXM1);
234 return 0;
235@@ -728,7 +737,9 @@ static void mcp251x_tx_work_handler(struct work_struct *ws)
236 mutex_lock(&priv->mcp_lock);
237 if (priv->tx_skb) {
238 if (priv->can.state == CAN_STATE_BUS_OFF) {
239+
240 mcp251x_clean(net);
241+
242 } else {
243 frame = (struct can_frame *)priv->tx_skb->data;
244
245@@ -827,21 +838,37 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
246
247 /* Update can state */
248 if (eflag & EFLG_TXBO) {
249+
250+ netdev_err(net, "err: bus off\n");
251+
252 new_state = CAN_STATE_BUS_OFF;
253 can_id |= CAN_ERR_BUSOFF;
254 } else if (eflag & EFLG_TXEP) {
255+
256+ netdev_err(net, "err: txep\n");
257+
258 new_state = CAN_STATE_ERROR_PASSIVE;
259 can_id |= CAN_ERR_CRTL;
260 data1 |= CAN_ERR_CRTL_TX_PASSIVE;
261+
262 } else if (eflag & EFLG_RXEP) {
263+
264+ netdev_err(net, "err: rxep\n");
265+
266 new_state = CAN_STATE_ERROR_PASSIVE;
267 can_id |= CAN_ERR_CRTL;
268 data1 |= CAN_ERR_CRTL_RX_PASSIVE;
269 } else if (eflag & EFLG_TXWAR) {
270+
271+ netdev_err(net, "err: txwar\n");
272+
273 new_state = CAN_STATE_ERROR_WARNING;
274 can_id |= CAN_ERR_CRTL;
275 data1 |= CAN_ERR_CRTL_TX_WARNING;
276 } else if (eflag & EFLG_RXWAR) {
277+
278+ netdev_err(net, "err: rxwar\n");
279+
280 new_state = CAN_STATE_ERROR_WARNING;
281 can_id |= CAN_ERR_CRTL;
282 data1 |= CAN_ERR_CRTL_RX_WARNING;
283@@ -918,7 +945,7 @@ static int mcp251x_open(struct net_device *net)
284
285 ret = open_candev(net);
286 if (ret) {
287- dev_err(&spi->dev, "unable to set initial baudrate!\n");
288+ netdev_err(net, "failed to open can device\n");
289 return ret;
290 }
291
292@@ -934,7 +961,7 @@ static int mcp251x_open(struct net_device *net)
293 pdata->irq_flags ? pdata->irq_flags : IRQF_TRIGGER_FALLING,
294 DEVICE_NAME, priv);
295 if (ret) {
296- dev_err(&spi->dev, "failed to acquire irq %d\n", spi->irq);
297+ netdev_err(net, "failed to acquire irq %d\n", spi->irq);
298 if (pdata->transceiver_enable)
299 pdata->transceiver_enable(0);
300 close_candev(net);
301@@ -1071,7 +1098,7 @@ static int __devinit mcp251x_can_probe(struct spi_device *spi)
302
303 ret = register_candev(net);
304 if (!ret) {
305- dev_info(&spi->dev, "probed\n");
306+ netdev_info(priv->net, "probed\n");
307 return ret;
308 }
309 error_probe:
310--
3111.7.2.5
312
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.2/beaglebone/defconfig b/recipes-kernel/linux/linux-ti33x-psp-3.2/beaglebone/defconfig
index f2c8b444..07b9987e 100644
--- a/recipes-kernel/linux/linux-ti33x-psp-3.2/beaglebone/defconfig
+++ b/recipes-kernel/linux/linux-ti33x-psp-3.2/beaglebone/defconfig
@@ -777,8 +777,8 @@ CONFIG_DNS_RESOLVER=y
777# 777#
778# CONFIG_NET_PKTGEN is not set 778# CONFIG_NET_PKTGEN is not set
779# CONFIG_HAMRADIO is not set 779# CONFIG_HAMRADIO is not set
780CONFIG_CAN=m 780CONFIG_CAN=y
781CONFIG_CAN_RAW=m 781CONFIG_CAN_RAW=y
782CONFIG_CAN_BCM=m 782CONFIG_CAN_BCM=m
783CONFIG_CAN_GW=m 783CONFIG_CAN_GW=m
784 784
@@ -787,14 +787,14 @@ CONFIG_CAN_GW=m
787# 787#
788CONFIG_CAN_VCAN=m 788CONFIG_CAN_VCAN=m
789CONFIG_CAN_SLCAN=m 789CONFIG_CAN_SLCAN=m
790CONFIG_CAN_DEV=m 790CONFIG_CAN_DEV=y
791CONFIG_CAN_CALC_BITTIMING=y 791CONFIG_CAN_CALC_BITTIMING=y
792CONFIG_CAN_TI_HECC=m 792CONFIG_CAN_TI_HECC=m
793# CONFIG_CAN_MCP251X is not set 793CONFIG_CAN_MCP251X=y
794# CONFIG_CAN_SJA1000 is not set 794# CONFIG_CAN_SJA1000 is not set
795# CONFIG_CAN_C_CAN is not set 795# CONFIG_CAN_C_CAN is not set
796CONFIG_CAN_D_CAN=m 796CONFIG_CAN_D_CAN=y
797CONFIG_CAN_D_CAN_PLATFORM=m 797CONFIG_CAN_D_CAN_PLATFORM=y
798 798
799# 799#
800# CAN USB interfaces 800# CAN USB interfaces
@@ -802,7 +802,7 @@ CONFIG_CAN_D_CAN_PLATFORM=m
802CONFIG_CAN_EMS_USB=m 802CONFIG_CAN_EMS_USB=m
803CONFIG_CAN_ESD_USB2=m 803CONFIG_CAN_ESD_USB2=m
804# CONFIG_CAN_SOFTING is not set 804# CONFIG_CAN_SOFTING is not set
805# CONFIG_CAN_DEBUG_DEVICES is not set 805CONFIG_CAN_DEBUG_DEVICES=y
806CONFIG_IRDA=m 806CONFIG_IRDA=m
807 807
808# 808#
diff --git a/recipes-kernel/linux/linux-ti33x-psp_3.2.bb b/recipes-kernel/linux/linux-ti33x-psp_3.2.bb
index 6c67129b..682fa8cd 100644
--- a/recipes-kernel/linux/linux-ti33x-psp_3.2.bb
+++ b/recipes-kernel/linux/linux-ti33x-psp_3.2.bb
@@ -11,7 +11,7 @@ MULTI_CONFIG_BASE_SUFFIX = ""
11 11
12BRANCH = "v3.2-staging" 12BRANCH = "v3.2-staging"
13SRCREV = "83d907e1b05dabc44f3bb64532d7b58d059a14c0" 13SRCREV = "83d907e1b05dabc44f3bb64532d7b58d059a14c0"
14MACHINE_KERNEL_PR_append = "c+gitr${SRCREV}" 14MACHINE_KERNEL_PR_append = "d+gitr${SRCREV}"
15 15
16COMPATIBLE_MACHINE = "(ti33x)" 16COMPATIBLE_MACHINE = "(ti33x)"
17 17
@@ -46,6 +46,7 @@ PATCHES_OVER_PSP = " \
46 file://0019-beaglebone-set-default-brightness-to-50-for-pwm-back.patch \ 46 file://0019-beaglebone-set-default-brightness-to-50-for-pwm-back.patch \
47 file://0020-st7735fb-WIP-framebuffer-driver-supporting-Adafruit-.patch \ 47 file://0020-st7735fb-WIP-framebuffer-driver-supporting-Adafruit-.patch \
48 file://0021-beaglebone-use-P8_6-gpio1_3-as-w1-bus.patch \ 48 file://0021-beaglebone-use-P8_6-gpio1_3-as-w1-bus.patch \
49 file://0022-beaglebone-add-support-for-Towertech-TT3201-CAN-cape.patch \
49" 50"
50 51
51SRC_URI += "${@base_contains('DISTRO_FEATURES', 'tipspkernel', "", "${PATCHES_OVER_PSP}", d)}" 52SRC_URI += "${@base_contains('DISTRO_FEATURES', 'tipspkernel', "", "${PATCHES_OVER_PSP}", d)}"