Skip to content

Commit ea99d87

Browse files
authored
Support kernel 5.10 (#69)
* Support kernel 5.10.x * Bump up tp 3.1.0 * Keep backward compatibility
1 parent 28b78c1 commit ea99d87

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

src/drivers/rtmouse.c

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* rtmouse.c
44
* Raspberry Pi Mouse device driver
55
*
6-
* Version: 3.0.0
6+
* Version: 3.1.0
77
*
8-
* Copyright (C) 2015-2020 RT Corporation <shop@rt-net.jp>
8+
* Copyright (C) 2015-2021 RT Corporation <shop@rt-net.jp>
99
*
1010
* This program is free software; you can redistribute it and/or modify
1111
* it under the terms of the GNU General Public License as published by
@@ -751,6 +751,7 @@ static int gpio_map(void)
751751
{
752752
static int clk_status = 1;
753753

754+
#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 0, 0)
754755
if (gpio_base == NULL) {
755756
gpio_base = ioremap_nocache(RPI_GPIO_BASE, RPI_GPIO_SIZE);
756757
}
@@ -762,6 +763,19 @@ static int gpio_map(void)
762763
if (clk_base == NULL) {
763764
clk_base = ioremap_nocache(RPI_CLK_BASE, RPI_CLK_SIZE);
764765
}
766+
#else
767+
if (gpio_base == NULL) {
768+
gpio_base = ioremap(RPI_GPIO_BASE, RPI_GPIO_SIZE);
769+
}
770+
771+
if (pwm_base == NULL) {
772+
pwm_base = ioremap(RPI_PWM_BASE, RPI_PWM_SIZE);
773+
}
774+
775+
if (clk_base == NULL) {
776+
clk_base = ioremap(RPI_CLK_BASE, RPI_CLK_SIZE);
777+
}
778+
#endif
765779

766780
/* kill */
767781
if (clk_status == 1) {
@@ -2058,6 +2072,7 @@ static int i2c_counter_init(void)
20582072
* 動的にデバイス実体を作成
20592073
* (https://www.kernel.org/doc/Documentation/i2c/instantiating-devices)
20602074
*/
2075+
#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 0, 0)
20612076
// printk(KERN_DEBUG "%s: adding i2c device", __func__);
20622077
i2c_adap_l = i2c_get_adapter(1);
20632078
i2c_client_l = i2c_new_device(i2c_adap_l, &i2c_board_info_l);
@@ -2069,7 +2084,19 @@ static int i2c_counter_init(void)
20692084
i2c_client_r = i2c_new_device(i2c_adap_r, &i2c_board_info_r);
20702085
i2c_put_adapter(i2c_adap_r);
20712086
// printk(KERN_DEBUG "%s: added i2c device rtcntr", __func__);
2087+
#else
2088+
// printk(KERN_DEBUG "%s: adding i2c device", __func__);
2089+
i2c_adap_l = i2c_get_adapter(1);
2090+
i2c_client_l = i2c_new_client_device(i2c_adap_l, &i2c_board_info_l);
2091+
i2c_put_adapter(i2c_adap_l);
2092+
// printk(KERN_DEBUG "%s: added i2c device rtcntl", __func__);
20722093

2094+
// printk(KERN_DEBUG "%s: adding i2c device", __func__);
2095+
i2c_adap_r = i2c_get_adapter(1);
2096+
i2c_client_r = i2c_new_client_device(i2c_adap_r, &i2c_board_info_r);
2097+
i2c_put_adapter(i2c_adap_r);
2098+
// printk(KERN_DEBUG "%s: added i2c device rtcntr", __func__);
2099+
#endif
20732100

20742101
return retval;
20752102
}

0 commit comments

Comments
 (0)