aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/pending-4.4/023-bcma-from-4.9.patch
blob: 027054c162e2a8d40f192a89d34999b13417566f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
--- a/drivers/bcma/driver_chipcommon.c
+++ b/drivers/bcma/driver_chipcommon.c
@@ -36,12 +36,31 @@ u32 bcma_chipco_get_alp_clock(struct bcm
 }
 EXPORT_SYMBOL_GPL(bcma_chipco_get_alp_clock);
 
+static bool bcma_core_cc_has_pmu_watchdog(struct bcma_drv_cc *cc)
+{
+	struct bcma_bus *bus = cc->core->bus;
+
+	if (cc->capabilities & BCMA_CC_CAP_PMU) {
+		if (bus->chipinfo.id == BCMA_CHIP_ID_BCM53573) {
+			WARN(bus->chipinfo.rev <= 1, "No watchdog available\n");
+			/* 53573B0 and 53573B1 have bugged PMU watchdog. It can
+			 * be enabled but timer can't be bumped. Use CC one
+			 * instead.
+			 */
+			return false;
+		}
+		return true;
+	} else {
+		return false;
+	}
+}
+
 static u32 bcma_chipco_watchdog_get_max_timer(struct bcma_drv_cc *cc)
 {
 	struct bcma_bus *bus = cc->core->bus;
 	u32 nb;
 
-	if (cc->capabilities & BCMA_CC_CAP_PMU) {
+	if (bcma_core_cc_has_pmu_watchdog(cc)) {
 		if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
 			nb = 32;
 		else if (cc->core->id.rev < 26)
@@ -95,9 +114,16 @@ static int bcma_chipco_watchdog_ticks_pe
 
 int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc)
 {
+	struct bcma_bus *bus = cc->core->bus;
 	struct bcm47xx_wdt wdt = {};
 	struct platform_device *pdev;
 
+	if (bus->chipinfo.id == BCMA_CHIP_ID_BCM53573 &&
+	    bus->chipinfo.rev <= 1) {
+		pr_debug("No watchdog on 53573A0 / 53573A1\n");
+		return 0;
+	}
+
 	wdt.driver_data = cc;
 	wdt.timer_set = bcma_chipco_watchdog_timer_set_wdt;
 	wdt.timer_set_ms = bcma_chipco_watchdog_timer_set_ms_wdt;
@@ -105,7 +131,7 @@ int bcma_chipco_watchdog_register(struct
 		bcma_chipco_watchdog_get_max_timer(cc) / cc->ticks_per_ms;
 
 	pdev = platform_device_register_data(NULL, "bcm47xx-wdt",
-					     cc->core->bus->num, &wdt,
+					     bus->num, &wdt,
 					     sizeof(wdt));
 	if (IS_ERR(pdev))
 		return PTR_ERR(pdev);
@@ -217,7 +243,7 @@ u32 bcma_chipco_watchdog_timer_set(struc
 	u32 maxt;
 
 	maxt = bcma_chipco_watchdog_get_max_timer(cc);
-	if (cc->capabilities & BCMA_CC_CAP_PMU) {
+	if (bcma_core_cc_has_pmu_watchdog(cc)) {
 		if (ticks == 1)
 			ticks = 2;
 		else if (ticks > maxt)
--- a/include/linux/bcma/bcma.h
+++ b/include/linux/bcma/bcma.h
@@ -204,6 +204,9 @@ struct bcma_host_ops {
 #define  BCMA_PKG_ID_BCM4709	0
 #define BCMA_CHIP_ID_BCM47094	53030
 #define BCMA_CHIP_ID_BCM53018	53018
+#define BCMA_CHIP_ID_BCM53573	53573
+#define  BCMA_PKG_ID_BCM53573	0
+#define  BCMA_PKG_ID_BCM47189	1
 
 /* Board types (on PCI usually equals to the subsystem dev id) */
 /* BCM4313 */
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -209,6 +209,8 @@ static void bcma_of_fill_device(struct p
 		core->dev.of_node = node;
 
 	core->irq = bcma_of_get_irq(parent, core, 0);
+
+	of_dma_configure(&core->dev, node);
 }
 
 unsigned int bcma_core_irq(struct bcma_device *core, int num)
@@ -248,12 +250,12 @@ void bcma_prepare_core(struct bcma_bus *
 		core->irq = bus->host_pci->irq;
 		break;
 	case BCMA_HOSTTYPE_SOC:
-		core->dev.dma_mask = &core->dev.coherent_dma_mask;
-		if (bus->host_pdev) {
+		if (IS_ENABLED(CONFIG_OF) && bus->host_pdev) {
 			core->dma_dev = &bus->host_pdev->dev;
 			core->dev.parent = &bus->host_pdev->dev;
 			bcma_of_fill_device(bus->host_pdev, core);
 		} else {
+			core->dev.dma_mask = &core->dev.coherent_dma_mask;
 			core->dma_dev = &core->dev;
 		}
 		break;
lp + If you say yes here you get support for the Pericom Technology + Inc. PT7C4338 RTC chip. + + This driver can also be built as a module. If so, the module + will be called rtc-pt7c4338. + endif # I2C comment "SPI RTC drivers" --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile @@ -116,6 +116,7 @@ obj-$(CONFIG_RTC_DRV_PL030) += rtc-pl030 obj-$(CONFIG_RTC_DRV_PL031) += rtc-pl031.o obj-$(CONFIG_RTC_DRV_PM8XXX) += rtc-pm8xxx.o obj-$(CONFIG_RTC_DRV_PS3) += rtc-ps3.o +obj-$(CONFIG_RTC_DRV_PT7C4338) += rtc-pt7c4338.o obj-$(CONFIG_RTC_DRV_PUV3) += rtc-puv3.o obj-$(CONFIG_RTC_DRV_PXA) += rtc-pxa.o obj-$(CONFIG_RTC_DRV_R9701) += rtc-r9701.o --- /dev/null +++ b/drivers/rtc/rtc-pt7c4338.c @@ -0,0 +1,216 @@ +/* + * Copyright 2010 Freescale Semiconductor, Inc. + * + * Author: Priyanka Jain <Priyanka.Jain@freescale.com> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +/* + * This file provides Date & Time support (no alarms) for PT7C4338 chip. + * + * This file is based on drivers/rtc/rtc-ds1307.c + * + * PT7C4338 chip is manufactured by Pericom Technology Inc. + * It is a serial real-time clock which provides + * 1)Low-power clock/calendar. + * 2)Programmable square-wave output. + * It has 56 bytes of nonvolatile RAM. + */ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/slab.h> +#include <linux/i2c.h> +#include <linux/rtc.h> +#include <linux/bcd.h> + +/* RTC register addresses */ +#define PT7C4338_REG_SECONDS 0x00 +#define PT7C4338_REG_MINUTES 0x01 +#define PT7C4338_REG_HOURS 0x02 +#define PT7C4338_REG_AMPM 0x02 +#define PT7C4338_REG_DAY 0x03 +#define PT7C4338_REG_DATE 0x04 +#define PT7C4338_REG_MONTH 0x05 +#define PT7C4338_REG_YEAR 0x06 +#define PT7C4338_REG_CTRL_STAT 0x07 + +/* RTC second register address bit */ +#define PT7C4338_SEC_BIT_CH 0x80 /*Clock Halt (in Register 0)*/ + +/* RTC control and status register bits */ +#define PT7C4338_CTRL_STAT_BIT_RS0 0x1 /*Rate select 0*/ +#define PT7C4338_CTRL_STAT_BIT_RS1 0x2 /*Rate select 1*/ +#define PT7C4338_CTRL_STAT_BIT_SQWE 0x10 /*Square Wave Enable*/ +#define PT7C4338_CTRL_STAT_BIT_OSF 0x20 /*Oscillator Stop Flag*/ +#define PT7C4338_CTRL_STAT_BIT_OUT 0x80 /*Output Level Control*/ + +static const struct i2c_device_id pt7c4338_id[] = { + { "pt7c4338", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, pt7c4338_id); + +struct pt7c4338{ + struct i2c_client *client; + struct rtc_device *rtc; +}; + +static int pt7c4338_read_time(struct device *dev, struct rtc_time *time) +{ + struct i2c_client *client = to_i2c_client(dev); + int ret; + u8 buf[7]; + u8 year, month, day, hour, minute, second; + u8 week, twelve_hr, am_pm; + + ret = i2c_smbus_read_i2c_block_data(client, + PT7C4338_REG_SECONDS, 7, buf); + if (ret < 0) + return ret; + if (ret < 7) + return -EIO; + + second = buf[0]; + minute = buf[1]; + hour = buf[2]; + week = buf[3]; + day = buf[4]; + month = buf[5]; + year = buf[6]; + + /* Extract additional information for AM/PM */ + twelve_hr = hour & 0x40; + am_pm = hour & 0x20; + + /* Write to rtc_time structure */ + time->tm_sec = bcd2bin(second & 0x7f); + time->tm_min = bcd2bin(minute & 0x7f); + if (twelve_hr) { + /* Convert to 24 hr */ + if (am_pm) + time->tm_hour = bcd2bin(hour & 0x10) + 12; + else + time->tm_hour = bcd2bin(hour & 0xBF); + } else { + time->tm_hour = bcd2bin(hour); + } + + time->tm_wday = bcd2bin(week & 0x07) - 1; + time->tm_mday = bcd2bin(day & 0x3f); + time->tm_mon = bcd2bin(month & 0x1F) - 1; + /* assume 20YY not 19YY */ + time->tm_year = bcd2bin(year) + 100; + + return 0; +} + +static int pt7c4338_set_time(struct device *dev, struct rtc_time *time) +{ + struct i2c_client *client = to_i2c_client(dev); + u8 buf[7]; + + /* Extract time from rtc_time and load into pt7c4338*/ + buf[0] = bin2bcd(time->tm_sec); + buf[1] = bin2bcd(time->tm_min); + buf[2] = bin2bcd(time->tm_hour); + buf[3] = bin2bcd(time->tm_wday + 1); /* Day of the week */ + buf[4] = bin2bcd(time->tm_mday); /* Date */ + buf[5] = bin2bcd(time->tm_mon + 1); + + /* assume 20YY not 19YY */ + if (time->tm_year >= 100) + buf[6] = bin2bcd(time->tm_year - 100); + else + buf[6] = bin2bcd(time->tm_year); + + return i2c_smbus_write_i2c_block_data(client, + PT7C4338_REG_SECONDS, 7, buf); +} + +static const struct rtc_class_ops pt7c4338_rtc_ops = { + .read_time = pt7c4338_read_time, + .set_time = pt7c4338_set_time, +}; + +static int pt7c4338_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct pt7c4338 *pt7c4338; + struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); + int ret; + + pt7c4338 = kzalloc(sizeof(struct pt7c4338), GFP_KERNEL); + if (!pt7c4338) + return -ENOMEM; + + pt7c4338->client = client; + i2c_set_clientdata(client, pt7c4338); + pt7c4338->rtc = rtc_device_register(client->name, &client->dev, + &pt7c4338_rtc_ops, THIS_MODULE); + if (IS_ERR(pt7c4338->rtc)) { + ret = PTR_ERR(pt7c4338->rtc); + dev_err(&client->dev, "unable to register the class device\n"); + goto out_free; + } + + return 0; +out_free: + i2c_set_clientdata(client, NULL); + kfree(pt7c4338); + return ret; +} + +static int pt7c4338_remove(struct i2c_client *client) +{ + struct pt7c4338 *pt7c4338 = i2c_get_clientdata(client); + + rtc_device_unregister(pt7c4338->rtc); + i2c_set_clientdata(client, NULL); + kfree(pt7c4338); + return 0; +} + +static struct i2c_driver pt7c4338_driver = { + .driver = { + .name = "rtc-pt7c4338", + .owner = THIS_MODULE, + }, + .probe = pt7c4338_probe, + .remove = pt7c4338_remove, + .id_table = pt7c4338_id, +}; + +static int __init pt7c4338_init(void) +{ + return i2c_add_driver(&pt7c4338_driver); +} + +static void __exit pt7c4338_exit(void) +{ + i2c_del_driver(&pt7c4338_driver); +} + +module_init(pt7c4338_init); +module_exit(pt7c4338_exit); + +MODULE_AUTHOR("Priyanka Jain <Priyanka.Jain@freescale.com>"); +MODULE_DESCRIPTION("pericom Technology Inc. PT7C4338 RTC Driver"); +MODULE_LICENSE("GPL");