1
0
mirror of https://git.yoctoproject.org/meta-ti synced 2026-05-07 03:49:20 +00:00

linux-ti335x-psp 3.1: add CAN bus patches

Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
This commit is contained in:
Koen Kooi
2011-11-10 15:43:47 +01:00
parent 0839c9df6a
commit 7915ef6f0e
8 changed files with 2320 additions and 0 deletions
@@ -786,6 +786,8 @@ CONFIG_CAN_TI_HECC=m
# CONFIG_CAN_MCP251X is not set
# CONFIG_CAN_SJA1000 is not set
# CONFIG_CAN_C_CAN is not set
CONFIG_CAN_D_CAN=m
CONFIG_CAN_D_CAN_PLATFORM=m
#
# CAN USB interfaces
@@ -0,0 +1,260 @@
From f2da2b163827a075c98f1897801c90bf736784a3 Mon Sep 17 00:00:00 2001
From: Anil Kumar Ch <anilkumar@ti.com>
Date: Sun, 6 Nov 2011 02:46:12 +0530
Subject: [PATCH 2/7] can: d_can: Added platform data for am33xx device
This patch adds the platform data needed by the driver. Added the
resources to the difference d_can instances.
Initialization of message ram is necessary to read/write the message object
from/into the message RAM
Signed-off-by: Anil Kumar Ch <anilkumar@ti.com>
---
arch/arm/mach-omap2/board-am335xevm.c | 131 ++++++++++++++++++++++++++++++
arch/arm/mach-omap2/clock33xx_data.c | 18 ++++
arch/arm/mach-omap2/mux33xx.c | 8 +-
arch/arm/plat-omap/include/plat/am33xx.h | 3 +
4 files changed, 156 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
index c84857e..6773f3b 100644
--- a/arch/arm/mach-omap2/board-am335xevm.c
+++ b/arch/arm/mach-omap2/board-am335xevm.c
@@ -24,6 +24,7 @@
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
#include <linux/platform_device.h>
+#include <linux/can/platform/d_can.h>
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/wl12xx.h>
@@ -50,6 +51,7 @@
/* LCD controller is similar to DA850 */
#include <video/da8xx-fb.h>
+#include "control.h"
#include "board-flash.h"
#include "mux.h"
#include "devices.h"
@@ -991,6 +993,133 @@ static void mmc2_wl12xx_init(int evm_id, int profile)
return;
}
+#define AM33XX_D_CAN_RAM_BASE 0x1000
+#define AM33XX_D_CAN_NUM_MSG_OBJS 64
+#define AM33XX_D_CAN_VERSION 0x1
+#define AM33XX_CTL_DCAN_RAMINIT_OFFSET 0x644
+#define AM33XX_D_CAN_RAMINIT_START(n) (0x1 << n)
+
+static void d_can_hw_raminit(unsigned int instance)
+{
+ u32 raminit_reg_val;
+
+ /* Read the value */
+ raminit_reg_val = __raw_readl(AM33XX_CTRL_REGADDR(
+ AM33XX_CTL_DCAN_RAMINIT_OFFSET));
+
+ /* Modify by setting "0" */
+ raminit_reg_val &= ~AM33XX_D_CAN_RAMINIT_START(instance);
+ __raw_writel(raminit_reg_val, AM33XX_CTRL_REGADDR(
+ AM33XX_CTL_DCAN_RAMINIT_OFFSET));
+
+ /* Reset to one */
+ raminit_reg_val |= AM33XX_D_CAN_RAMINIT_START(instance);
+ __raw_writel(raminit_reg_val, AM33XX_CTRL_REGADDR(
+ AM33XX_CTL_DCAN_RAMINIT_OFFSET));
+ udelay(10);
+}
+
+static struct d_can_platform_data am33xx_evm_d_can_pdata = {
+ .d_can_offset = 0,
+ .d_can_ram_offset = AM33XX_D_CAN_RAM_BASE,
+ .num_of_msg_objs = AM33XX_D_CAN_NUM_MSG_OBJS,
+ .dma_support = false,
+ .test_mode_enable = false,
+ .parity_check = false,
+ .version = AM33XX_D_CAN_VERSION,
+ .hw_raminit = d_can_hw_raminit,
+};
+
+static struct resource am33xx_d_can0_resources[] = {
+ {
+ .start = AM33XX_D_CAN0_BASE,
+ .end = AM33XX_D_CAN0_BASE + 0x3FFF,
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .name = "d_can_int0",
+ .start = AM33XX_IRQ_DCAN0_0,
+ .end = AM33XX_IRQ_DCAN0_0,
+ .flags = IORESOURCE_IRQ,
+ },
+ {
+ .name = "d_can_int1",
+ .start = AM33XX_IRQ_DCAN0_1,
+ .end = AM33XX_IRQ_DCAN0_1,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct platform_device am33xx_d_can0_device = {
+ .dev = {
+ .platform_data = &am33xx_evm_d_can_pdata,
+ },
+ .name = "d_can",
+ .id = 0,
+ .num_resources = ARRAY_SIZE(am33xx_d_can0_resources),
+ .resource = am33xx_d_can0_resources,
+};
+
+static struct pinmux_config d_can0_pin_mux[] = {
+ {"uart1_ctsn.d_can0_tx", OMAP_MUX_MODE2 | AM33XX_PULL_ENBL},
+ {"uart1_rtsn.d_can0_rx", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLUP},
+ {NULL, 0},
+};
+
+static void d_can0_init(int evm_id, int profile)
+{
+ /* For instance 0 */
+ if (profile == PROFILE_1) {
+ setup_pin_mux(d_can0_pin_mux);
+ platform_device_register(&am33xx_d_can0_device);
+ }
+}
+
+/* DCAN instnace 1 specific resources */
+static struct resource am33xx_d_can1_resources[] = {
+ {
+ .start = AM33XX_D_CAN1_BASE,
+ .end = AM33XX_D_CAN1_BASE + 0x3FFF,
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .name = "d_can_int0",
+ .start = AM33XX_IRQ_DCAN1_0,
+ .end = AM33XX_IRQ_DCAN1_0,
+ .flags = IORESOURCE_IRQ,
+ },
+ {
+ .name = "d_can_int1",
+ .start = AM33XX_IRQ_DCAN1_1,
+ .end = AM33XX_IRQ_DCAN1_1,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct platform_device am33xx_d_can1_device = {
+ .dev = {
+ .platform_data = &am33xx_evm_d_can_pdata,
+ },
+ .name = "d_can",
+ .id = 1,
+ .num_resources = ARRAY_SIZE(am33xx_d_can1_resources),
+ .resource = am33xx_d_can1_resources,
+};
+
+static struct pinmux_config d_can1_pin_mux[] = {
+ {"uart1_rxd.d_can1_tx", OMAP_MUX_MODE2 | AM33XX_PULL_ENBL},
+ {"uart1_txd.d_can1_rx", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLUP},
+ {NULL, 0},
+};
+
+static void d_can1_init(int evm_id, int profile)
+{
+ /* For instance 1 */
+ if (profile == PROFILE_4) {
+ setup_pin_mux(d_can1_pin_mux);
+ platform_device_register(&am33xx_d_can1_device);
+ }
+}
static void uart1_wl12xx_init(int evm_id, int profile)
{
setup_pin_mux(uart1_wl12xx_pin_mux);
@@ -1194,6 +1323,8 @@ static struct evm_dev_cfg gen_purp_evm_dev_cfg[] = {
{uart1_wl12xx_init, DEV_ON_BASEBOARD, (PROFILE_0 | PROFILE_3 |
PROFILE_5)},
{wl12xx_init, DEV_ON_BASEBOARD, (PROFILE_0 | PROFILE_3 | PROFILE_5)},
+ {d_can0_init, DEV_ON_BASEBOARD, PROFILE_1},
+ {d_can1_init, DEV_ON_BASEBOARD, PROFILE_4},
{NULL, 0, 0},
};
diff --git a/arch/arm/mach-omap2/clock33xx_data.c b/arch/arm/mach-omap2/clock33xx_data.c
index 6763c59..d8670f2 100644
--- a/arch/arm/mach-omap2/clock33xx_data.c
+++ b/arch/arm/mach-omap2/clock33xx_data.c
@@ -421,6 +421,22 @@ static struct clk dcan1_fck = {
.recalc = &followparent_recalc,
};
+static struct clk dcan0_ick = {
+ .name = "dcan0_ick",
+ .parent = &dpll_per_m2_ck ,
+ .ops = &clkops_null,
+ .clkdm_name = "l4ls_clkdm",
+ .recalc = &followparent_recalc,
+};
+
+static struct clk dcan1_ick = {
+ .name = "dcan1_ick",
+ .parent = &dpll_per_m2_ck ,
+ .ops = &clkops_null,
+ .clkdm_name = "l4ls_clkdm",
+ .recalc = &followparent_recalc,
+};
+
static struct clk debugss_fck = {
.name = "debugss_fck",
.ops = &clkops_omap2_dflt,
@@ -1771,6 +1787,8 @@ static struct omap_clk am33xx_clks[] = {
CLK("cpsw.0", NULL, &cpgmac0_fck, CK_AM33XX),
CLK(NULL, "dcan0_fck", &dcan0_fck, CK_AM33XX),
CLK(NULL, "dcan1_fck", &dcan1_fck, CK_AM33XX),
+ CLK(NULL, "dcan0_ick", &dcan0_ick, CK_AM33XX),
+ CLK(NULL, "dcan1_ick", &dcan1_ick, CK_AM33XX),
CLK(NULL, "debugss_fck", &debugss_fck, CK_AM33XX),
CLK(NULL, "elm_fck", &elm_fck, CK_AM33XX),
CLK(NULL, "emif_fck", &emif_fck, CK_AM33XX),
diff --git a/arch/arm/mach-omap2/mux33xx.c b/arch/arm/mach-omap2/mux33xx.c
index 0286c4f..8232b46 100644
--- a/arch/arm/mach-omap2/mux33xx.c
+++ b/arch/arm/mach-omap2/mux33xx.c
@@ -315,16 +315,16 @@ static struct omap_mux __initdata am33xx_muxmodes[] = {
"uart0_txd", "spi1_cs1", NULL, NULL,
NULL, NULL, NULL, NULL),
_AM33XX_MUXENTRY(UART1_CTSN, 0,
- "uart1_ctsn", NULL, NULL, NULL,
+ "uart1_ctsn", NULL, "d_can0_tx", NULL,
"spi1_cs0", NULL, NULL, NULL),
_AM33XX_MUXENTRY(UART1_RTSN, 0,
- "uart1_rtsn", NULL, NULL, NULL,
+ "uart1_rtsn", NULL, "d_can0_rx", NULL,
"spi1_cs1", NULL, NULL, NULL),
_AM33XX_MUXENTRY(UART1_RXD, 0,
- "uart1_rxd", "mmc1_sdwp", NULL, NULL,
+ "uart1_rxd", "mmc1_sdwp", "d_can1_tx", NULL,
NULL, NULL, NULL, NULL),
_AM33XX_MUXENTRY(UART1_TXD, 0,
- "uart1_txd", "mmc2_sdwp", NULL, NULL,
+ "uart1_txd", "mmc2_sdwp", "d_can1_rx", NULL,
NULL, NULL, NULL, NULL),
_AM33XX_MUXENTRY(I2C0_SDA, 0,
"i2c0_sda", NULL, NULL, NULL,
diff --git a/arch/arm/plat-omap/include/plat/am33xx.h b/arch/arm/plat-omap/include/plat/am33xx.h
index a77c38e..cfd1883 100644
--- a/arch/arm/plat-omap/include/plat/am33xx.h
+++ b/arch/arm/plat-omap/include/plat/am33xx.h
@@ -30,6 +30,9 @@
#define AM33XX_TSC_BASE 0x44E0D000
#define AM33XX_RTC_BASE 0x44E3E000
+#define AM33XX_D_CAN0_BASE 0x481CC000
+#define AM33XX_D_CAN1_BASE 0x481D0000
+
#define AM33XX_ASP0_BASE 0x48038000
#define AM33XX_ASP1_BASE 0x4803C000
--
1.7.2.5
@@ -0,0 +1,57 @@
From 68a9166b306c9b7a542a8ddcf31cc5fa738f52b3 Mon Sep 17 00:00:00 2001
From: Anil Kumar Ch <anilkumar@ti.com>
Date: Sun, 6 Nov 2011 10:44:26 +0530
Subject: [PATCH 3/7] can: d_can: DCAN config added to am335x_evm_defconfig
This patch adds the DCAN and dependent modules configurations
to am335x_evm_defconfig
Dependent modules are:
CONFIG_CAN_RAW
CONFIG_CAN_BCM
Signed-off-by: Anil Kumar Ch <anilkumar@ti.com>
---
arch/arm/configs/am335x_evm_defconfig | 26 +++++++++++++++++++++++++-
1 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/arch/arm/configs/am335x_evm_defconfig b/arch/arm/configs/am335x_evm_defconfig
index 02ee0c3..a90dffd 100644
--- a/arch/arm/configs/am335x_evm_defconfig
+++ b/arch/arm/configs/am335x_evm_defconfig
@@ -658,7 +658,31 @@ CONFIG_DNS_RESOLVER=y
#
# CONFIG_NET_PKTGEN is not set
# CONFIG_HAMRADIO is not set
-# CONFIG_CAN is not set
+CONFIG_CAN=y
+CONFIG_CAN_RAW=y
+CONFIG_CAN_BCM=y
+
+#
+# CAN Device Drivers
+#
+# CONFIG_CAN_VCAN is not set
+# CONFIG_CAN_SLCAN is not set
+CONFIG_CAN_DEV=y
+CONFIG_CAN_CALC_BITTIMING=y
+# CONFIG_CAN_TI_HECC is not set
+# CONFIG_CAN_MCP251X is not set
+# CONFIG_CAN_SJA1000 is not set
+# CONFIG_CAN_C_CAN is not set
+CONFIG_CAN_D_CAN=y
+CONFIG_CAN_D_CAN_PLATFORM=y
+
+#
+# CAN USB interfaces
+#
+# CONFIG_CAN_EMS_USB is not set
+# CONFIG_CAN_ESD_USB2 is not set
+# CONFIG_CAN_SOFTING is not set
+# CONFIG_CAN_DEBUG_DEVICES is not set
# CONFIG_IRDA is not set
CONFIG_BT=y
CONFIG_BT_L2CAP=y
--
1.7.2.5
@@ -0,0 +1,49 @@
From 3788f8da920468db766e5e8ec03785d2fc2c8f12 Mon Sep 17 00:00:00 2001
From: Anil Kumar Ch <anilkumar@ti.com>
Date: Thu, 10 Nov 2011 12:36:12 +0530
Subject: [PATCH 4/7] can: d_can: fix for cansend loop issue
The specified number of packets are not transmitting with the
help of cansend --loop=10. This pacth fixes the issue and able
to transmit upto 32 packets. This limitation is because of no.
of objects availability on AM335X
Signed-off-by: Anil Kumar Ch <anilkumar@ti.com>
---
drivers/net/can/d_can/d_can.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/can/d_can/d_can.c b/drivers/net/can/d_can/d_can.c
index e001db0..d31b019 100644
--- a/drivers/net/can/d_can/d_can.c
+++ b/drivers/net/can/d_can/d_can.c
@@ -611,7 +611,7 @@ static inline int d_can_is_next_tx_obj_busy(struct d_can_priv *priv, int objno)
* message object n, we need to handle the same properly.
*/
if (d_can_read(priv, D_CAN_TXRQ(txrq_x_reg_val)) &
- (1 << (objno - 1)))
+ (1 << (objno - D_CAN_MSG_OBJ_TX_FIRST)))
return 1;
return 0;
@@ -858,7 +858,8 @@ static void d_can_do_tx(struct net_device *dev)
msg_obj_no = get_tx_echo_msg_obj(priv);
txrq_x_reg_val = D_CAN_GET_XREG_NUM(priv, D_CAN_TXRQ_X);
txrq_reg_val = d_can_read(priv, D_CAN_TXRQ(txrq_x_reg_val));
- if (!(txrq_reg_val & (1 << (msg_obj_no - 1)))) {
+ if (!(txrq_reg_val & (1 << (msg_obj_no -
+ D_CAN_MSG_OBJ_TX_FIRST)))) {
can_get_echo_skb(dev,
msg_obj_no - D_CAN_MSG_OBJ_TX_FIRST);
stats->tx_bytes += d_can_read(priv,
@@ -1124,7 +1125,6 @@ static int d_can_poll(struct napi_struct *napi, int quota)
struct net_device *dev = napi->dev;
struct d_can_priv *priv = netdev_priv(dev);
- priv->irqstatus = d_can_read(priv, D_CAN_INT);
if (!priv->irqstatus)
goto end;
--
1.7.2.5
@@ -0,0 +1,60 @@
From 332ec54d00463875532584604f364fc4347d918b Mon Sep 17 00:00:00 2001
From: Anil Kumar Ch <anilkumar@ti.com>
Date: Thu, 10 Nov 2011 17:59:16 +0530
Subject: [PATCH 5/7] can: d_can: fixes the rmmod crash
This patch fixes the rmmod crash while unloading the
DCAN driver from the kernel.
Signed-off-by: Anil Kumar Ch <anilkumar@ti.com>
---
drivers/net/can/d_can/d_can_platform.c | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/net/can/d_can/d_can_platform.c b/drivers/net/can/d_can/d_can_platform.c
index b430a18..859756b 100644
--- a/drivers/net/can/d_can/d_can_platform.c
+++ b/drivers/net/can/d_can/d_can_platform.c
@@ -190,7 +190,6 @@ exit_iounmap:
exit_release_mem:
release_mem_region(mem->start, resource_size(mem));
exit_free_clks:
-#ifdef CONFIG_HAVE_CLK
clk_disable(priv->ick);
clk_put(priv->ick);
exit_free_fck:
@@ -199,7 +198,6 @@ exit_free_fck:
exit_free_ndev:
free_d_can_dev(ndev);
exit:
-#endif
dev_err(&pdev->dev, "probe failed\n");
return ret;
@@ -211,18 +209,19 @@ static int __devexit d_can_plat_remove(struct platform_device *pdev)
struct d_can_priv *priv = netdev_priv(ndev);
struct resource *mem;
+ unregister_d_can_dev(ndev);
+ platform_set_drvdata(pdev, NULL);
+
free_d_can_dev(ndev);
iounmap(priv->base);
+
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(mem->start, resource_size(mem));
-#ifdef CONFIG_HAVE_CLK
+
clk_disable(priv->ick);
clk_disable(priv->fck);
clk_put(priv->ick);
clk_put(priv->fck);
-#endif
- unregister_d_can_dev(ndev);
- platform_set_drvdata(pdev, NULL);
return 0;
}
--
1.7.2.5
@@ -0,0 +1,47 @@
From 0aea3e2629cd1681d8d8e6e0a4409959b31ea4e9 Mon Sep 17 00:00:00 2001
From: Anil Kumar Ch <anilkumar@ti.com>
Date: Thu, 10 Nov 2011 15:21:47 +0100
Subject: [PATCH 7/7] can: d_can: am335x profile modification for dcan0
This patch modifies the profile information of am335x device.
Profile reads of cpld_client from smbus gives an error leads to put
the device into default profile 0. So by default the board configured
to beaglebone even if we set the sw8 switch on daughter card to other
profiles.
This patch makes all the IO connecters are configured in profile 1.
Signed-off-by: Anil Kumar Ch <anilkumar@ti.com>
---
arch/arm/mach-omap2/board-am335xevm.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
index 590c4ca..ac64fc7 100644
--- a/arch/arm/mach-omap2/board-am335xevm.c
+++ b/arch/arm/mach-omap2/board-am335xevm.c
@@ -340,6 +340,9 @@ static u32 am335x_get_profile_selection(void)
{
int val = 0;
+ /* FIXME: temporary fix */
+ return 1;
+
if (!cpld_client)
/* error checking is not done in func's calling this routine.
so return profile 0 on error */
@@ -1721,8 +1724,8 @@ out:
*/
pr_err("Could not detect any board, falling back to: "
"Beaglebone (< Rev A3) with no daughter card connected\n");
- daughter_brd_detected = false;
- setup_beaglebone_old();
+ daughter_brd_detected = true;
+ setup_general_purpose_evm();
/* Initialize cpsw after board detection is completed as board
* information is required for configuring phy address and hence
--
1.7.2.5
@@ -35,6 +35,12 @@ PATCHES_OVER_PSP = " \
file://0003-arm-omap-mcspi-correct-memory-range-when-requesting-.patch \
file://0004-arm-omap-mcspi-follow-proper-pm_runtime-enable-disab.patch \
file://0005-arm-omap-mcspi-follow-proper-probe-remove-steps.patch \
file://can/0001-can-d_can-Added-support-for-Bosch-D_CAN-controller.patch \
file://can/0002-can-d_can-Added-platform-data-for-am33xx-device.patch \
file://can/0003-can-d_can-DCAN-config-added-to-am335x_evm_defconfig.patch \
file://can/0004-can-d_can-fix-for-cansend-loop-issue.patch \
file://can/0005-can-d_can-fixes-the-rmmod-crash.patch \
file://can/0007-can-d_can-am335x-profile-modification-for-dcan0.patch \
"
SRC_URI += "${@base_contains('DISTRO_FEATURES', 'tipspkernel', "", "${PATCHES_OVER_PSP}", d)}"