aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ramips/patches-4.3/0014-arch-mips-cleanup-cevt-rt3352.patch
diff options
context:
space:
mode:
authorJohn Crispin <john@openwrt.org>2015-12-10 19:06:32 +0000
committerJohn Crispin <john@openwrt.org>2015-12-10 19:06:32 +0000
commit6df4426245be87148d6aa75859951cb6351eb24c (patch)
tree57a361566f8a505f89b685125d9ab36bba289e19 /target/linux/ramips/patches-4.3/0014-arch-mips-cleanup-cevt-rt3352.patch
parentf2b0ae86983705c98a50ae845403e67c9c412f4d (diff)
downloadupstream-6df4426245be87148d6aa75859951cb6351eb24c.tar.gz
upstream-6df4426245be87148d6aa75859951cb6351eb24c.tar.bz2
upstream-6df4426245be87148d6aa75859951cb6351eb24c.zip
ralink: bump to the target to v4.3
Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 47831
Diffstat (limited to 'target/linux/ramips/patches-4.3/0014-arch-mips-cleanup-cevt-rt3352.patch')
-rw-r--r--target/linux/ramips/patches-4.3/0014-arch-mips-cleanup-cevt-rt3352.patch170
1 files changed, 170 insertions, 0 deletions
diff --git a/target/linux/ramips/patches-4.3/0014-arch-mips-cleanup-cevt-rt3352.patch b/target/linux/ramips/patches-4.3/0014-arch-mips-cleanup-cevt-rt3352.patch
new file mode 100644
index 0000000000..d6410505c7
--- /dev/null
+++ b/target/linux/ramips/patches-4.3/0014-arch-mips-cleanup-cevt-rt3352.patch
@@ -0,0 +1,170 @@
+From e6ed424c36458aff8738fb1fbb0141196678058a Mon Sep 17 00:00:00 2001
+From: John Crispin <blogic@openwrt.org>
+Date: Mon, 7 Dec 2015 17:17:23 +0100
+Subject: [PATCH 14/53] arch: mips: cleanup cevt-rt3352
+
+Signed-off-by: John Crispin <blogic@openwrt.org>
+---
+ arch/mips/ralink/cevt-rt3352.c | 85 ++++++++++++++++++++++++++--------------
+ 1 file changed, 56 insertions(+), 29 deletions(-)
+
+diff --git a/arch/mips/ralink/cevt-rt3352.c b/arch/mips/ralink/cevt-rt3352.c
+index cecf44f..424635c 100644
+--- a/arch/mips/ralink/cevt-rt3352.c
++++ b/arch/mips/ralink/cevt-rt3352.c
+@@ -52,7 +52,7 @@ static inline void mt7620_freq_scaling(struct systick_device *sdev, int status)
+
+ sdev->freq_scale = status;
+
+- pr_info("%s: %s autosleep mode\n", systick.dev.name,
++ pr_info("%s: %s autosleep mode\n", sdev->dev.name,
+ (status) ? ("enable") : ("disable"));
+ if (status)
+ rt_sysc_w32(rt_sysc_r32(CLK_LUT_CFG) | SLEEP_EN, CLK_LUT_CFG);
+@@ -60,18 +60,33 @@ static inline void mt7620_freq_scaling(struct systick_device *sdev, int status)
+ rt_sysc_w32(rt_sysc_r32(CLK_LUT_CFG) & ~SLEEP_EN, CLK_LUT_CFG);
+ }
+
++static inline unsigned int read_count(struct systick_device *sdev)
++{
++ return ioread32(sdev->membase + SYSTICK_COUNT);
++}
++
++static inline unsigned int read_compare(struct systick_device *sdev)
++{
++ return ioread32(sdev->membase + SYSTICK_COMPARE);
++}
++
++static inline void write_compare(struct systick_device *sdev, unsigned int val)
++{
++ iowrite32(val, sdev->membase + SYSTICK_COMPARE);
++}
++
+ static int systick_next_event(unsigned long delta,
+ struct clock_event_device *evt)
+ {
+ struct systick_device *sdev;
+- u32 count;
++ int res;
+
+ sdev = container_of(evt, struct systick_device, dev);
+- count = ioread32(sdev->membase + SYSTICK_COUNT);
+- count = (count + delta) % SYSTICK_FREQ;
+- iowrite32(count, sdev->membase + SYSTICK_COMPARE);
++ delta += read_count(sdev);
++ write_compare(sdev, delta);
++ res = ((int)(read_count(sdev) - delta) >= 0) ? -ETIME : 0;
+
+- return 0;
++ return res;
+ }
+
+ static void systick_event_handler(struct clock_event_device *dev)
+@@ -81,20 +96,25 @@ static void systick_event_handler(struct clock_event_device *dev)
+
+ static irqreturn_t systick_interrupt(int irq, void *dev_id)
+ {
+- struct clock_event_device *dev = (struct clock_event_device *) dev_id;
++ int ret = 0;
++ struct clock_event_device *cdev;
++ struct systick_device *sdev;
++
++ if (read_c0_cause() & STATUSF_IP7) {
++ cdev = (struct clock_event_device *) dev_id;
++ sdev = container_of(cdev, struct systick_device, dev);
+
+- dev->event_handler(dev);
++ /* Clear Count/Compare Interrupt */
++ write_compare(sdev, read_compare(sdev));
++ cdev->event_handler(cdev);
++ ret = 1;
++ }
+
+- return IRQ_HANDLED;
++ return IRQ_RETVAL(ret);
+ }
+
+ static struct systick_device systick = {
+ .dev = {
+- /*
+- * cevt-r4k uses 300, make sure systick
+- * gets used if available
+- */
+- .rating = 310,
+ .features = CLOCK_EVT_FEAT_ONESHOT,
+ .set_next_event = systick_next_event,
+ .set_state_shutdown = systick_shutdown,
+@@ -116,9 +136,9 @@ static int systick_shutdown(struct clock_event_device *evt)
+ sdev = container_of(evt, struct systick_device, dev);
+
+ if (sdev->irq_requested)
+- free_irq(systick.dev.irq, &systick_irqaction);
++ remove_irq(systick.dev.irq, &systick_irqaction);
+ sdev->irq_requested = 0;
+- iowrite32(0, systick.membase + SYSTICK_CONFIG);
++ iowrite32(CFG_CNT_EN, systick.membase + SYSTICK_CONFIG);
+
+ if (systick_freq_scaling)
+ systick_freq_scaling(sdev, 0);
+@@ -145,38 +165,45 @@ static int systick_set_oneshot(struct clock_event_device *evt)
+ }
+
+ static const struct of_device_id systick_match[] = {
+- { .compatible = "ralink,mt7620-systick", .data = mt7620_freq_scaling},
++ { .compatible = "ralink,mt7620a-systick", .data = mt7620_freq_scaling},
+ {},
+ };
+
+ static void __init ralink_systick_init(struct device_node *np)
+ {
+ const struct of_device_id *match;
++ int rating = 200;
+
+ systick.membase = of_iomap(np, 0);
+ if (!systick.membase)
+ return;
+
+ match = of_match_node(systick_match, np);
+- if (match)
++ if (match) {
+ systick_freq_scaling = match->data;
++ /*
++ * cevt-r4k uses 300, make sure systick
++ * gets used if available
++ */
++ rating = 310;
++ }
+
+- systick_irqaction.name = np->name;
+- systick.dev.name = np->name;
+- clockevents_calc_mult_shift(&systick.dev, SYSTICK_FREQ, 60);
+- systick.dev.max_delta_ns = clockevent_delta2ns(0x7fff, &systick.dev);
+- systick.dev.min_delta_ns = clockevent_delta2ns(0x3, &systick.dev);
++ /* enable counter than register clock source */
++ iowrite32(CFG_CNT_EN, systick.membase + SYSTICK_CONFIG);
++ clocksource_mmio_init(systick.membase + SYSTICK_COUNT, np->name,
++ SYSTICK_FREQ, rating, 16, clocksource_mmio_readl_up);
++
++ /* register clock event */
+ systick.dev.irq = irq_of_parse_and_map(np, 0);
+ if (!systick.dev.irq) {
+ pr_err("%s: request_irq failed", np->name);
+ return;
+ }
+-
+- clocksource_mmio_init(systick.membase + SYSTICK_COUNT, np->name,
+- SYSTICK_FREQ, 301, 16, clocksource_mmio_readl_up);
+-
+- clockevents_register_device(&systick.dev);
+-
++ systick_irqaction.name = np->name;
++ systick.dev.name = np->name;
++ systick.dev.rating = rating;
++ systick.dev.cpumask = cpumask_of(0);
++ clockevents_config_and_register(&systick.dev, SYSTICK_FREQ, 0x3, 0x7fff);
+ pr_info("%s: running - mult: %d, shift: %d\n",
+ np->name, systick.dev.mult, systick.dev.shift);
+ }
+--
+1.7.10.4
+