Add lscanfd.ko (6965e5fa1627)

lscanfd.ko is in driver/net/can/ls_can.

usage:
insmod lscanfd.ko
insmod lscanfd_platform.ko
This commit is contained in:
tao89959
2024-08-12 20:22:20 +08:00
committed by loongson
parent 79c4598505
commit b212174b4f
18 changed files with 264 additions and 37 deletions
@@ -25,6 +25,8 @@
spi1 = &spi1;
spi2 = &spi2;
spi3 = &spi3;
ethernet0 = &gmac0;
ethernet1 = &gmac1;
};
cpus {
@@ -123,6 +125,10 @@
pinctrl-single,bits = <0x10 0x000000a0 0xf00000f0>;
};
gmac1_pins: pinmux_G44_G55_as_gmac1 {
pinctrl-single,bits = <0x8 0x55000000 0xff000000
0xc 0x00005555 0x0000ffff>;
};
i2c0_pins: pinmux_G48_G49_as_i2c0 {
pinctrl-single,bits = <0xc 0x0000000f 0x0000000f>;
};
@@ -151,6 +157,10 @@
pinctrl-single,bits = <0x10 0x000000ff 0x000000ff>;
};
spi2_cs_as_gpio: pinmux_G64_G66_as_spi2 {
pinctrl-single,bits = <0x10 0x0000003f 0x000000ff>;
};
can0_pins: pinmux_G68_G69_as_can0 {
pinctrl-single,bits = <0x10 0x00000f00 0x00000f00>;
};
@@ -436,8 +446,8 @@
interrupt-names = "macirq";
dma-mask = <0xffffffff 0xffffffff>;
phy-mode = "rgmii";
// pinctrl-0 = <&gmac1_pins>;
// pinctrl-names = "default";
pinctrl-0 = <&gmac1_pins>;
pinctrl-names = "default";
snps,pbl = <32>;
status = "disabled";
};
@@ -483,46 +493,58 @@
};
can0: can@0x16110000 {
compatible = "ls,lscanfd";
compatible = "loongson,ls-canfd";
reg = <0 0x16110000 0 0x400>;
ls,clock-frequency = <200000000>;
ls,canfd-dmarx;
interrupt-parent = <&icu>;
interrupts = <8>;
pinctrl-0 = <&can0_pins>;
pinctrl-names = "default";
dmas = <&dma 0 0xaae>;
dma-names = "rx";
status = "disabled";
};
can1: can@0x16111000 {
compatible = "ls,lscanfd";
compatible = "loongson,ls-canfd";
reg = <0 0x16110400 0 0x400>;
ls,clock-frequency = <200000000>;
ls,canfd-dmarx;
interrupt-parent = <&icu>;
interrupts = <9>;
pinctrl-0 = <&can1_pins>;
pinctrl-names = "default";
dmas = <&dma 1 0xaae>;
dma-names = "rx";
status = "disabled";
};
can2: can@0x16112000 {
compatible = "ls,lscanfd";
compatible = "loongson,ls-canfd";
reg = <0 0x16110800 0 0x400>;
ls,clock-frequency = <200000000>;
ls,canfd-dmarx;
interrupt-parent = <&icu>;
interrupts = <10>;
pinctrl-0 = <&can2_pins>;
pinctrl-names = "default";
dmas = <&dma 2 0xaae>;
dma-names = "rx";
status = "disabled";
};
can3: can@0x16113000 {
compatible = "ls,lscanfd";
compatible = "loongson,ls-canfd";
reg = <0 0x16110c00 0 0x400>;
ls,clock-frequency = <200000000>;
ls,canfd-dmarx;
interrupt-parent = <&icu>;
interrupts = <11>;
pinctrl-0 = <&can3_pins>;
pinctrl-names = "default";
dmas = <&dma 3 0xaae>;
dma-names = "rx";
status = "disabled";
};
@@ -622,7 +644,7 @@
status = "disabled";
};
iodma: iodma@0x1612c000{
dma: dma@0x1612c000{
compatible = "loongson,lsia-dma";
reg = <0 0x1612c000 0 0x100>;
#config-nr = <2>;
@@ -788,8 +810,8 @@
audio: audio@0x16114000 {
compatible = "loongson,ls-pcm-generic-audio";
reg = <0 0x16114000 0 0x4000>;
dmas = <&iodma 0 0xaf
&iodma 1 0xbf>;
dmas = <&dma 0 0xaf
&dma 1 0xbf>;
dma-names = "i2s_record", "i2s_play";
dma-mask = <0xffffffff 0xffffffff>;
status = "disabled";
@@ -412,7 +412,7 @@
uart4: serial@0x15100000 {
compatible = "ns16550a";
reg = <0 0x15100000 0 0x10>;
clock-frequency = <200000000>;
clock-frequency = <100000000>;
//interrupt-parent = <&extioiic>;
interrupt-parent = <&icu>;
interrupts = <39>;
@@ -425,7 +425,7 @@
uart5: serial@0x15100800 {
compatible = "ns16550a";
reg = <0 0x15100800 0 0x10>;
clock-frequency = <200000000>;
clock-frequency = <100000000>;
//interrupt-parent = <&extioiic>;
interrupt-parent = <&icu>;
interrupts = <39>;
@@ -438,7 +438,7 @@
uart6: serial@0x15200000 {
compatible = "ns16550a";
reg = <0 0x15200000 0 0x10>;
clock-frequency = <200000000>;
clock-frequency = <100000000>;
//interrupt-parent = <&extioiic>;
interrupt-parent = <&icu>;
interrupts = <53>;
@@ -451,7 +451,7 @@
uart7: serial@0x15200800 {
compatible = "ns16550a";
reg = <0 0x15200800 0 0x10>;
clock-frequency = <200000000>;
clock-frequency = <100000000>;
//interrupt-parent = <&extioiic>;
interrupt-parent = <&icu>;
interrupts = <54>;
@@ -71,5 +71,28 @@
pixelclk-active = <0>;
};
};
panel-ATK-MD1010R-1280x800{
width-mm = <229>;
height-mm = <149>;
label = "ATK-MD1010R-1280x800";
data-mapping = "jeida-24";
panel-timing {
clock-frequency = <71100000>;
hactive = <1280>;
vactive = <800>;
hsync-len = <10>;
hfront-porch = <70>;
hback-porch = <80>;
vfront-porch = <10>;
vback-porch = <10>;
vsync-len = <3>;
de-active = <1>;
hsync-active = <0>;
vsync-active = <0>;
pixelclk-active = <0>;
};
};
};
};
@@ -18,11 +18,17 @@
};
lcd_backlight: backlight {
compatible = "gpio-backlight";
gpios = <&gpio 84 GPIO_ACTIVE_HIGH>;
default-on;
};
panel: dvo-connector@0 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "panel-lvds", "auo,b101ean01";
//backlight = <&lcd_backlight>;
backlight = <&lcd_backlight>;
/* lcd power on control gpio */
// enable-gpios = <&pioA 3 GPIO_ACTIVE_HIGH>;
@@ -49,7 +49,7 @@
lcd_backlight: backlight {
compatible = "gpio-backlight";
gpios = <&gpio 43 GPIO_ACTIVE_HIGH>;
status = "okay";
default-on;
};
panel: dvo-connector@0 {
@@ -141,6 +141,7 @@
onewire {
compatible = "w1-gpio";
gpios = <&gpio 68 GPIO_ACTIVE_HIGH>;
status = "disabled";
};
};
@@ -180,16 +181,33 @@
&spi1 {
status = "okay";
spidev0@0 {
compatible = "rohm,dh2228fv";
reg = <0>;
spi-max-frequency = <25000000>;
};
};
&spi2 {
status = "ok"
pinctrl-0 = <&spi2_cs_as_gpio>;
pinctrl-names = "default";
num-chipselects = <2>;
cs-gpios = <&gpio 67 0>,
<&gpio 85 0>;
mcp3004@0 {
compatible = "mcp3004";
reg = <0>;
spi-max-frequency = <1500000>;
};
spidev1@1 {
compatible = "rohm,dh2228fv";
reg = <1>;
spi-max-frequency = <25000000>;
};
};
&gmac0 {
@@ -304,8 +322,4 @@
&sound {
status = "okay";
};
&pwm0 {
status = "okay";
};
};
@@ -1,4 +1,5 @@
CONFIG_LOCALVERSION=".lsgd"
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_SYSVIPC=y
CONFIG_POSIX_MQUEUE=y
CONFIG_NO_HZ=y
@@ -1,4 +1,5 @@
CONFIG_LOCALVERSION=".lsgd"
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_SYSVIPC=y
CONFIG_POSIX_MQUEUE=y
CONFIG_NO_HZ=y
@@ -1,4 +1,5 @@
CONFIG_LOCALVERSION=".lsgd"
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_DEFAULT_HOSTNAME="Loongson(GD)"
CONFIG_SYSVIPC=y
CONFIG_POSIX_MQUEUE=y
@@ -1,4 +1,5 @@
CONFIG_LOCALVERSION=".lsgd"
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_DEFAULT_HOSTNAME="Loongson(GD)"
CONFIG_SYSVIPC=y
CONFIG_POSIX_MQUEUE=y
Executable
+49
View File
@@ -0,0 +1,49 @@
#!/bin/bash
set -e
PS3="Please enter your choice:"
conf=""
function get_conf()
{
plat=loongson_${1}
opts=(`cd arch/loongarch/configs && ls ${plat}*`)
select opt in "${opts[@]}"
do
conf=$opt
break
done
echo
echo "Your select is:${conf}"
echo
}
function usage()
{
echo "Usage:"
echo "./buildenv.sh <chip> [options]"
echo "chip: <2k300/2k500/2k1000/2p500/all>"
echo "options: it's same as u-boot make defconfig"
}
function main()
{
if [ $# -ge 1 ]; then
param=${1}
if [ ${param} = "all" ]; then
get_conf
else
get_conf $param
fi
shift
make $conf $@
else
usage
fi
}
main $@
+5 -5
View File
@@ -242,11 +242,11 @@ static void ls_i2c_handle_read(struct ls_i2c_dev *i2c_dev, int flag)
complete(&i2c_dev->complete);
break;
case 3:
i2c_clr_bits(reg, I2C_CR2_ITBUFEN);
// 必须 delay 至少 100us
udelay(500);
if (flag != 1)
if (readl(i2c_dev->base + I2C_CR2) & I2C_CR2_ITBUFEN) {
i2c_clr_bits(reg, I2C_CR2_ITBUFEN);
break;
}
reg = i2c_dev->base + I2C_CR1;
i2c_clr_bits(reg, I2C_CR1_ACK);
default:
@@ -476,7 +476,7 @@ static int ls_i2c_probe(struct platform_device *pdev)
}
i2c_dev->speed = LS_I2C_SPEED_STANDARD;
of_property_read_u32(np, "i2c-speed", &clk_rate);
ret = of_property_read_u32(np, "i2c-speed", &clk_rate);
if (!ret && clk_rate >= 400000)
i2c_dev->speed = LS_I2C_SPEED_FAST;
+1 -1
View File
@@ -217,7 +217,7 @@ static ssize_t lio_write (struct file *file,
}
} else {
for (i = 0; i < size; i += 2) {
iowrite16(kbuf[i], ptr+i);
iowrite16((kbuf[i+1] << 8 | kbuf[i]), ptr+i);
}
}
Binary file not shown.
Binary file not shown.
+102 -9
View File
@@ -138,6 +138,8 @@ struct ls_spiio_priv {
u32 ref_clk;
u32 clk;
u8 dsize;
struct gpio_desc **cs_gpios;
struct device *dev;
};
static int ls_spiio_idle_sr1(struct ls_spiio_priv* priv, u32 bit)
@@ -148,19 +150,90 @@ static int ls_spiio_idle_sr1(struct ls_spiio_priv* priv, u32 bit)
return timeout;
}
static int ls_spiio_set_cs(struct ls_spiio_priv* priv, int cs)
static int ls_spiio_active_cs(struct ls_spiio_priv* priv, int cs)
{
ls_spiio_write_reg(priv, REG_CR1,
BIT_CR1_SSREV | BIT_CR1_SPE);
int active = 0;
if (!priv->cs_gpios)
ls_spiio_write_reg(priv, REG_CR1, BIT_CR1_SSREV | BIT_CR1_SPE);
else
gpiod_set_raw_value(priv->cs_gpios[cs], active);
return 0;
}
static int ls_spiio_clear_cs(struct ls_spiio_priv* priv)
{
ls_spiio_write_reg(priv, REG_CR1, BIT_CR1_SSREV);
struct spi_master* master = priv->master;
int clear = 1;
int i;
if (!priv->cs_gpios)
ls_spiio_write_reg(priv, REG_CR1, BIT_CR1_SSREV);
else
for (i = 0; i < master->num_chipselect; i++)
gpiod_set_raw_value(priv->cs_gpios[i], clear);
return 0;
}
static int ls_spiio_free_cs_gpios(struct ls_spiio_priv* priv)
{
struct spi_master* master = priv->master;
struct device *dev = priv->dev;
int i;
if (!priv->cs_gpios)
return 0;
for (i = 0; i < master->num_chipselect; i++)
devm_gpiod_put(dev, priv->cs_gpios[i]);
devm_kfree(dev, priv->cs_gpios);
return 0;
}
static int ls_spiio_init_cs_gpios(struct ls_spiio_priv* priv)
{
struct spi_master* master = priv->master;
struct device *dev = priv->dev;
int clear = 1;
int ret;
int i;
priv->cs_gpios = devm_kcalloc(dev, master->num_chipselect,
sizeof(*priv->cs_gpios),
GFP_KERNEL);
if (!priv->cs_gpios)
return -ENOMEM;
for (i = 0; i < master->num_chipselect; i++) {
priv->cs_gpios[i] = devm_gpiod_get_index(dev, "cs", i,
GPIOD_OUT_HIGH);
if (IS_ERR(priv->cs_gpios[i]))
{
ret = PTR_ERR(priv->cs_gpios[i]);
dev_err(dev, "Cannot Requst cs-gpio[%d]: %d\n",
i, ret);
goto free_cs_gpio_array;
}
else
{
dev_info(dev, "GPIO[%d] as cs[%d]\n",
desc_to_gpio(priv->cs_gpios[i]), i);
gpiod_direction_output_raw(priv->cs_gpios[i], clear);
}
}
return 0;
free_cs_gpio_array:
devm_kfree(dev, priv->cs_gpios);
return ret;
}
static int ls_spiio_xfer(struct ls_spiio_priv* priv, u8* tx, u8* rx, int len)
{
int remain = len;
@@ -294,7 +367,7 @@ static int __spi_transfer(struct spi_device *spi, struct spi_message *m)
m->actual_length = 0;
m->status = 0;
ls_spiio_set_cs(priv, spi->chip_select);
ls_spiio_active_cs(priv, spi->chip_select);
list_for_each_entry(t, &m->transfers, transfer_list) {
/*setup spi clock*/
ls_spiio_set_clk_timing(priv, t->speed_hz, spi->mode);
@@ -310,8 +383,10 @@ static int __spi_transfer(struct spi_device *spi, struct spi_message *m)
static int drv_ls_spiio_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct ls_spiio_priv* priv;
struct spi_master* master;
u32 num_chipselect;
int ret;
master = spi_alloc_master(&pdev->dev, sizeof(*priv));
@@ -328,30 +403,45 @@ static int drv_ls_spiio_probe(struct platform_device *pdev)
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;
master->setup = __spi_setup;
master->transfer = __spi_transfer;
master->num_chipselect = 1;
if (of_property_read_u32(pdev->dev.of_node, "num-chipselects",
&num_chipselect))
num_chipselect = 1;
master->num_chipselect = num_chipselect ? num_chipselect : 1;
#ifdef CONFIG_OF
master->dev.of_node = of_node_get(pdev->dev.of_node);
#endif
dev_set_drvdata(&pdev->dev, master);
priv = spi_master_get_devdata(master);
priv->master = master;
priv->dev = dev;
if (of_find_property(pdev->dev.of_node, "cs-gpios", NULL))
{
ret = ls_spiio_init_cs_gpios(priv);
if (ret)
goto free_master;
}
priv->reg = devm_platform_ioremap_resource(pdev, 0);
if (priv->reg == NULL) {
dev_err(&pdev->dev, "Cannot map IO\n");
ret = -ENXIO;
goto try_free_cs_gpios;
}
if (of_property_read_u32(pdev->dev.of_node, "clock-frequency",
&priv->ref_clk))
{
dev_err(&pdev->dev, "Cannot get clock\n");
goto free_master;
goto try_free_cs_gpios;
}
priv->master = master;
ls_spiio_init(priv);
ret = spi_register_master(master);
if (ret < 0)
if (ret)
{
dev_err(&pdev->dev, "spi register fail\n");
goto unmap_io;
@@ -361,6 +451,9 @@ static int drv_ls_spiio_probe(struct platform_device *pdev)
unmap_io:
devm_iounmap(&pdev->dev, priv->reg);
try_free_cs_gpios:
if (of_find_property(pdev->dev.of_node, "cs-gpios", NULL))
ls_spiio_free_cs_gpios(priv);
free_master:
spi_master_put(master);
err:
@@ -195,7 +195,7 @@ extern void rtl871x_cedbg(const char *fmt, ...);
#define DRIVER_PREFIX "RTL871X: "
#if defined(_dbgdump)
#ifdef CONFIG_DEBUG_RTL871X
#define DBG_871X_EXP(level, EXP) do { if (level <= GlobalDebugLevel) EXP; } while (0)
/* with driver-defined prefix */
@@ -221,7 +221,13 @@ extern void rtl871x_cedbg(const char *fmt, ...);
_dbgdump(fmt, ##arg);\
}\
}while(0)
#else
#define DBG_871X_EXP(level, EXP) do { } while (0)
#undef DBG_871X_LEVEL
#define DBG_871X_LEVEL(level, fmt, arg...) do { } while (0)
#undef _DBG_871X_LEVEL
#define _DBG_871X_LEVEL(level, fmt, arg...) do { } while (0)
#endif
#if defined(_seqdump)
#define RTW_DBGDUMP 0 /* 'stream' for _dbgdump */
@@ -1521,11 +1521,13 @@ int rockchip_wifi_init_module(void)
int type = get_wifi_chip_type();
if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return 0;
#endif
#ifdef CONFIG_DEBUG_RTL871X
printk("\n");
printk("=======================================================\n");
printk("==== Launching Wi-Fi driver! (Powered by Rockchip) ====\n");
printk("=======================================================\n");
printk("Realtek 8188FU USB WiFi driver (Powered by Rockchip) init.\n");
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0))
#if 0
rockchip_wifi_power(1);
@@ -1548,11 +1550,13 @@ void rockchip_wifi_exit_module(void)
int type = get_wifi_chip_type();
if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return;
#endif
#ifdef CONFIG_DEBUG_RTL871X
printk("\n");
printk("=======================================================\n");
printk("==== Dislaunching Wi-Fi driver! (Powered by Rockchip) ====\n");
printk("=======================================================\n");
printk("Realtek 8188FU USB WiFi driver (Powered by Rockchip) init.\n");
#endif
rtw_drv_halt();
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0))
//rockchip_wifi_set_carddetect(0);
+6
View File
@@ -46,6 +46,12 @@ if [ -n "$SMP" ] ; then CONFIG_FLAGS="SMP"; fi
if [ -n "$PREEMPT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT"; fi
if [ -n "$PREEMPT_RT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT_RT"; fi
if [ -f "kernel_git_info" ]; then
CONFIG_FLAGS="$CONFIG_FLAGS g"$(cat kernel_git_info)
elif [ -d ".git" ]; then
CONFIG_FLAGS="$CONFIG_FLAGS g"$(git rev-parse --short HEAD)
fi
# Truncate to maximum length
UTS_LEN=64
UTS_VERSION="$(echo $UTS_VERSION $CONFIG_FLAGS $TIMESTAMP | cut -b -$UTS_LEN)"