Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions arch/arm64/boot/dts/amlogic/kvim3_linux.dts
Original file line number Diff line number Diff line change
Expand Up @@ -1409,13 +1409,12 @@
pinctrl-0 = <&spicc1_pins>;
cs-gpios = <&gpio GPIOH_6 0>;

spidev@0 {
spidev@1 {
status = "okay";

compatible = "linux,spidev";
/* spi default max clock 100Mhz */
spi-max-frequency = <100000000>;
reg = <0>;
reg = <1>;
};
};

Expand Down
4 changes: 2 additions & 2 deletions arch/arm64/boot/dts/amlogic/kvim3l_linux.dts
Original file line number Diff line number Diff line change
Expand Up @@ -1789,13 +1789,13 @@
pinctrl-0 = <&spicc1_pins>;
cs-gpios = <&gpio GPIOH_6 0>;

spidev@0 {
spidev@1 {
status = "okay";

compatible = "linux,spidev";
/* spi default max clock 100Mhz */
spi-max-frequency = <100000000>;
reg = <0>;
reg = <1>;
};
};

Expand Down
3 changes: 2 additions & 1 deletion arch/arm64/boot/dts/amlogic/overlays/kvim3/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ dtbo-y += uart3.dtbo \
m2x-eth.dtbo \
otg-device.dtbo \
watchdog.dtbo \
i2s.dtbo
i2s.dtbo \
can.dtbo

targets += $(dtbo-y)
always := $(dtbo-y)
50 changes: 50 additions & 0 deletions arch/arm64/boot/dts/amlogic/overlays/kvim3/can.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/meson-g12a-gpio.h>
#include <dt-bindings/gpio/gpio.h>

/ {
fragment@0 {
target = <&spicc1>;

__overlay__ {
status = "okay";

can0: mcp2515@0 {
spi-max-frequency = <2000000>;
compatible = "microchip,mcp2515";
reg = <0>;
int-gpio = <&gpio GPIOA_15 GPIO_ACTIVE_LOW>;
status = "okay";
};
};
};

fragment@1 {
target = <&i2c3>;

__overlay__ {
status = "disabled";
};
};

fragment@2 {
target = <&pwm_ef>;

__overlay__ {
// NOTE: This syntax DOES NOT work on device tree overlays
// If you want to use SPI1, you have to remove pwm_f overlay
/delete-property/ pinctrl-names;
/delete-property/ pinctrl-0;
};
};

fragment@3 {
target = <&uart_C>;

__overlay__ {
status = "disabled";
};
};
};
3 changes: 2 additions & 1 deletion arch/arm64/boot/dts/amlogic/overlays/kvim3l/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ dtbo-y += uart3.dtbo \
m2x-eth.dtbo \
otg-device.dtbo \
watchdog.dtbo \
i2s.dtbo
i2s.dtbo \
can.dtbo

targets += $(dtbo-y)
always := $(dtbo-y)
50 changes: 50 additions & 0 deletions arch/arm64/boot/dts/amlogic/overlays/kvim3l/can.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/meson-g12a-gpio.h>
#include <dt-bindings/gpio/gpio.h>

/ {
fragment@0 {
target = <&spicc1>;

__overlay__ {
status = "okay";

can0: mcp2515@0 {
spi-max-frequency = <2000000>;
compatible = "microchip,mcp2515";
reg = <0>;
int-gpio = <&gpio GPIOA_15 GPIO_ACTIVE_LOW>;
status = "okay";
};
};
};

fragment@1 {
target = <&i2c3>;

__overlay__ {
status = "disabled";
};
};

fragment@2 {
target = <&pwm_ef>;

__overlay__ {
// NOTE: This syntax DOES NOT work on device tree overlays
// If you want to use SPI1, you have to remove pwm_f overlay
/delete-property/ pinctrl-names;
/delete-property/ pinctrl-0;
};
};

fragment@3 {
target = <&uart_C>;

__overlay__ {
status = "disabled";
};
};
};
3 changes: 3 additions & 0 deletions arch/arm64/configs/kvims_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ CONFIG_NET_ACT_GACT=y
CONFIG_NET_ACT_MIRRED=y
CONFIG_NET_L3_MASTER_DEV=y
CONFIG_CGROUP_NET_PRIO=y
CONFIG_CAN=y
CONFIG_CAN_VCAN=m
CONFIG_CAN_MCP251X=y
CONFIG_BT=y
CONFIG_BT_RFCOMM=y
CONFIG_BT_RFCOMM_TTY=y
Expand Down
12 changes: 9 additions & 3 deletions drivers/net/can/spi/mcp251x.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
#include <linux/spi/spi.h>
#include <linux/uaccess.h>
#include <linux/regulator/consumer.h>
#include <linux/of_gpio.h>
#include <linux/gpio.h>
#include <asm/irq.h>

/* SPI interface instruction set */
#define INSTRUCTION_WRITE 0x02
Expand Down Expand Up @@ -1044,21 +1047,22 @@ static int mcp251x_can_probe(struct spi_device *spi)
{
const struct of_device_id *of_id = of_match_device(mcp251x_of_match,
&spi->dev);
struct mcp251x_platform_data *pdata = dev_get_platdata(&spi->dev);
// struct mcp251x_platform_data *pdata = dev_get_platdata(&spi->dev);
struct net_device *net;
struct mcp251x_priv *priv;
struct clk *clk;
int freq, ret;

clk = devm_clk_get(&spi->dev, NULL);
/* clk = devm_clk_get(&spi->dev, NULL);
if (IS_ERR(clk)) {
if (pdata)
freq = pdata->oscillator_frequency;
else
return PTR_ERR(clk);
} else {
freq = clk_get_rate(clk);
}
}*/
freq = 11000000;

/* Sanity check */
if (freq < 1000000 || freq > 25000000)
Expand Down Expand Up @@ -1111,6 +1115,8 @@ static int mcp251x_can_probe(struct spi_device *spi)
goto out_clk;
}

spi->irq = gpio_to_irq(of_get_named_gpio(spi->dev.of_node, "int-gpio", 0));

ret = mcp251x_power_enable(priv->power, 1);
if (ret)
goto out_clk;
Expand Down