+++ /dev/null
-obj-y = clock.o irq/
-
-obj-$(CONFIG_CPU_RX610) += rx610/
-obj-$(CONFIG_CPU_RX62N) += rx62n/
-obj-$(CONFIG_CPU_RX64M) += rx64m/
+++ /dev/null
-/*
- * arch/rx/kernel/cpu/clock.c - RX clock framework
- *
- * Based on SH version by:
- *
- * Copyright (C) 2005 - 2009 Paul Mundt
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/list.h>
-#include <linux/kobject.h>
-#include <linux/seq_file.h>
-#include <linux/err.h>
-#include <linux/platform_device.h>
-#include <linux/debugfs.h>
-#include <linux/cpufreq.h>
-#include <asm/clock.h>
-#include <asm/io.h>
-
-static LIST_HEAD(clock_list);
-static DEFINE_SPINLOCK(clock_lock);
-static DEFINE_MUTEX(clock_list_sem);
-
-static void __clk_disable(struct clk *clk)
-{
- if (clk->usecount == 0) {
- printk(KERN_ERR "Trying disable clock %s with 0 usecount\n",
- clk->name);
- WARN_ON(1);
- return;
- }
-
- if (!(--clk->usecount)) {
- if (likely(clk->mstpcr)) {
- unsigned char mstpcr;
- mstpcr = __raw_readb(clk->mstpcr);
- mstpcr |= clk->mstpbit;
- __raw_writeb(mstpcr,clk->mstpcr);
- }
- if (likely(clk->parent))
- __clk_disable(clk->parent);
- }
-}
-
-void clk_disable(struct clk *clk)
-{
- unsigned long flags;
-
- if (!clk)
- return;
-
- spin_lock_irqsave(&clock_lock, flags);
- __clk_disable(clk);
- spin_unlock_irqrestore(&clock_lock, flags);
-}
-EXPORT_SYMBOL_GPL(clk_disable);
-
-static int __clk_enable(struct clk *clk)
-{
- int ret = 0;
-
- if (clk->usecount++ == 0) {
- if (clk->parent) {
- ret = __clk_enable(clk->parent);
- if (unlikely(ret))
- goto err;
- }
- if (likely(clk->mstpcr)) {
- unsigned char mstpcr;
- mstpcr = __raw_readb(clk->mstpcr);
- mstpcr &= ~clk->mstpbit;
- __raw_writeb(mstpcr,clk->mstpcr);
- }
- }
-
- return ret;
-err:
- clk->usecount--;
- return ret;
-}
-
-int clk_enable(struct clk *clk)
-{
- unsigned long flags;
- int ret;
-
- if (!clk)
- return -EINVAL;
-
- spin_lock_irqsave(&clock_lock, flags);
- ret = __clk_enable(clk);
- spin_unlock_irqrestore(&clock_lock, flags);
-
- return ret;
-}
-EXPORT_SYMBOL_GPL(clk_enable);
-
-static LIST_HEAD(root_clks);
-
-int clk_register(struct clk *clk)
-{
- if (clk == NULL || IS_ERR(clk))
- return -EINVAL;
-
- /*
- * trap out already registered clocks
- */
- if (clk->node.next || clk->node.prev)
- return 0;
-
- mutex_lock(&clock_list_sem);
-
- INIT_LIST_HEAD(&clk->children);
- clk->usecount = 0;
-
- if (clk->parent)
- list_add(&clk->sibling, &clk->parent->children);
- else
- list_add(&clk->sibling, &root_clks);
-
- list_add(&clk->node, &clock_list);
- mutex_unlock(&clock_list_sem);
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(clk_register);
-
-void clk_unregister(struct clk *clk)
-{
- mutex_lock(&clock_list_sem);
- list_del(&clk->sibling);
- list_del(&clk->node);
- mutex_unlock(&clock_list_sem);
-}
-EXPORT_SYMBOL_GPL(clk_unregister);
-
-static void clk_enable_init_clocks(void)
-{
- struct clk *clkp;
-
- list_for_each_entry(clkp, &clock_list, node)
- if (clkp->flags & CLK_ENABLE_ON_INIT)
- clk_enable(clkp);
-}
-
-int clk_reparent(struct clk *child, struct clk *parent)
-{
- list_del_init(&child->sibling);
- if (parent)
- list_add(&child->sibling, &parent->children);
- child->parent = parent;
-
- /* now do the debugfs renaming to reattach the child
- to the proper parent */
-
- return 0;
-}
-
-unsigned long clk_get_rate(struct clk *clk)
-{
- return clk->rate?clk->rate:clk->selectable[clk->nr_selectable];
-}
-EXPORT_SYMBOL_GPL(clk_get_rate);
-
-int clk_set_rate(struct clk *clk, unsigned long rate)
-{
- int ret = -EOPNOTSUPP;
- unsigned long flags;
- struct clk *clkp;
-
- spin_lock_irqsave(&clock_lock, flags);
-
- if (likely(clk->set_rate)) {
- ret = clk->set_rate(clk, rate);
- if (ret != 0)
- goto out_unlock;
- } else {
- clk->rate = rate;
- ret = 0;
- }
- list_for_each_entry(clkp, &clk->children, sibling)
- if (likely(clk->update))
- clk->update(clkp);
-out_unlock:
- spin_unlock_irqrestore(&clock_lock, flags);
-
- return ret;
-}
-EXPORT_SYMBOL_GPL(clk_set_rate);
-
-int clk_set_parent(struct clk *clk, struct clk *parent)
-{
- unsigned long flags;
- int ret = -EINVAL;
-
- if (!parent || !clk)
- return ret;
- if (clk->parent == parent)
- return 0;
-
- spin_lock_irqsave(&clock_lock, flags);
- if (clk->usecount == 0) {
- ret = clk_reparent(clk, parent);
-
- if (ret == 0) {
- pr_debug("clock: set parent of %s to %s (new rate %ld)\n",
- clk->name, clk->parent->name, clk->rate);
- }
- } else
- ret = -EBUSY;
- spin_unlock_irqrestore(&clock_lock, flags);
-
- return ret;
-}
-EXPORT_SYMBOL_GPL(clk_set_parent);
-
-struct clk *clk_get_parent(struct clk *clk)
-{
- return clk->parent;
-}
-EXPORT_SYMBOL_GPL(clk_get_parent);
-
-long clk_round_rate(struct clk *clk, unsigned long rate)
-{
- unsigned long flags;
- if (clk->nr_selectable > 0) {
- int idx, roundclk;
-
- spin_lock_irqsave(&clock_lock, flags);
- roundclk = clk->selectable[clk->nr_selectable - 1];
- for(idx = 0; idx < clk->nr_selectable; idx++) {
- if (rate < clk->selectable[idx]) {
- if (idx > 0 &&
- ((rate - clk->selectable[idx - 1]) < (clk->selectable[idx ])))
- roundclk = clk->selectable[idx - 1];
- else
- roundclk = clk->selectable[idx];
- break;
- }
- }
- spin_unlock_irqrestore(&clock_lock, flags);
-
- return roundclk;
- }
-
- return clk_get_rate(clk);
-}
-EXPORT_SYMBOL_GPL(clk_round_rate);
-
-/*
- * Find the correct struct clk for the device and connection ID.
- * We do slightly fuzzy matching here:
- * An entry with a NULL ID is assumed to be a wildcard.
- * If an entry has a device ID, it must match
- * If an entry has a connection ID, it must match
- * Then we take the most specific entry - with the following
- * order of precidence: dev+con > dev only > con only.
- */
-static struct clk *clk_find(const char *dev_id, const char *con_id)
-{
- struct clk_lookup *p;
- struct clk *clk = NULL;
- int match, best = 0;
-
- list_for_each_entry(p, &clock_list, node) {
- match = 0;
- if (p->dev_id) {
- if (!dev_id || strcmp(p->dev_id, dev_id))
- continue;
- match += 2;
- }
- if (p->con_id) {
- if (!con_id || strcmp(p->con_id, con_id))
- continue;
- match += 1;
- }
- if (match == 0)
- continue;
-
- if (match > best) {
- clk = p->clk;
- best = match;
- }
- }
- return clk;
-}
-
-struct clk *clk_get_sys(const char *dev_id, const char *con_id)
-{
- struct clk *clk;
-
- mutex_lock(&clock_list_sem);
- clk = clk_find(dev_id, con_id);
- mutex_unlock(&clock_list_sem);
-
- return clk ? clk : ERR_PTR(-ENOENT);
-}
-EXPORT_SYMBOL_GPL(clk_get_sys);
-
-/*
- * Returns a clock. Note that we first try to use device id on the bus
- * and clock name. If this fails, we try to use clock name only.
- */
-struct clk *clk_get(struct device *dev, const char *id)
-{
- const char *dev_id = dev ? dev_name(dev) : NULL;
- struct clk *p, *clk = ERR_PTR(-ENOENT);
- int idno;
-
- clk = clk_get_sys(dev_id, id);
- if (clk && !IS_ERR(clk))
- return clk;
-
- if (dev == NULL || dev->bus != &platform_bus_type)
- idno = -1;
- else
- idno = to_platform_device(dev)->id;
-
- mutex_lock(&clock_list_sem);
- list_for_each_entry(p, &clock_list, node) {
- if (p->id == idno &&
- strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
- clk = p;
- goto found;
- }
- }
-
- list_for_each_entry(p, &clock_list, node) {
- if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
- clk = p;
- break;
- }
- }
-
-found:
- mutex_unlock(&clock_list_sem);
-
- return clk;
-}
-EXPORT_SYMBOL_GPL(clk_get);
-
-void clk_put(struct clk *clk)
-{
- if (clk && !IS_ERR(clk))
- module_put(clk->owner);
-}
-EXPORT_SYMBOL_GPL(clk_put);
-
-int __init clk_init(void)
-{
- int ret;
- struct clk *clkp;
- struct clk *child_clkp;
-
- ret = arch_clk_init();
- if (unlikely(ret)) {
- pr_err("%s: CPU clock registration failed.\n", __func__);
- return ret;
- }
-
- list_for_each_entry(clkp, &root_clks, sibling) {
- if (likely(clkp->update))
- clkp->update(clkp);
- list_for_each_entry(child_clkp, &clkp->children, sibling) {
- if (likely(child_clkp->update))
- child_clkp->update(child_clkp);
- }
- }
-
- /* Enable the necessary init clocks */
- clk_enable_init_clocks();
-
- return ret;
-}
-
-#ifdef CONFIG_DEBUG_FS
-/*
- * debugfs support to trace clock tree hierarchy and attributes
- */
-static struct dentry *clk_debugfs_root;
-
-static int clk_debugfs_register_one(struct clk *c)
-{
- int err;
- struct dentry *d, *child;
- struct clk *pa = c->parent;
- char s[255];
- char *p = s;
-
- p += sprintf(p, "%s", c->name);
- if (c->id >= 0)
- sprintf(p, ":%d", c->id);
- d = debugfs_create_dir(s, pa ? pa->dentry : clk_debugfs_root);
- if (!d)
- return -ENOMEM;
- c->dentry = d;
-
- d = debugfs_create_u8("usecount", S_IRUGO, c->dentry, (u8 *)&c->usecount);
- if (!d) {
- err = -ENOMEM;
- goto err_out;
- }
- d = debugfs_create_u32("rate", S_IRUGO, c->dentry, (u32 *)&c->rate);
- if (!d) {
- err = -ENOMEM;
- goto err_out;
- }
- d = debugfs_create_x32("flags", S_IRUGO, c->dentry, (u32 *)&c->flags);
- if (!d) {
- err = -ENOMEM;
- goto err_out;
- }
- return 0;
-
-err_out:
- d = c->dentry;
- list_for_each_entry(child, &d->d_subdirs, d_u.d_child)
- debugfs_remove(child);
- debugfs_remove(c->dentry);
- return err;
-}
-
-static int clk_debugfs_register(struct clk *c)
-{
- int err;
- struct clk *pa = c->parent;
-
- if (pa && !pa->dentry) {
- err = clk_debugfs_register(pa);
- if (err)
- return err;
- }
-
- if (!c->dentry) {
- err = clk_debugfs_register_one(c);
- if (err)
- return err;
- }
- return 0;
-}
-
-static int __init clk_debugfs_init(void)
-{
- struct clk *c;
- struct dentry *d;
- int err;
-
- d = debugfs_create_dir("clock", NULL);
- if (!d)
- return -ENOMEM;
- clk_debugfs_root = d;
-
- list_for_each_entry(c, &clock_list, node) {
- err = clk_debugfs_register(c);
- if (err)
- goto err_out;
- }
- return 0;
-err_out:
- debugfs_remove(clk_debugfs_root); /* REVISIT: Cleanup correctly */
- return err;
-}
-late_initcall(clk_debugfs_init);
-#endif
+++ /dev/null
-obj-$(CONFIG_RX_ICUA) = icua.o
+++ /dev/null
-/*
- * Interrupt handling for RX ICUa
- *
- * Copyright (C) 2011 Yoshinori Sato
- *
- */
-
-#include <linux/linkage.h>
-#include <linux/interrupt.h>
-#include <linux/export.h>
-#include <asm/io.h>
-
-#define IR (0x00087000)
-#define IER (0x00087200)
-#define IPR (0x00087300)
-
-static void disable_icua_irq(struct irq_data *data);
-static void enable_icua_irq(struct irq_data *data);
-static void icua_eoi(struct irq_data *data);
-
-struct irq_chip chip = {
- .name = "RX-ICUa",
- .irq_mask = disable_icua_irq,
- .irq_unmask = enable_icua_irq,
- .irq_eoi = icua_eoi,
- .irq_mask_ack = disable_icua_irq,
-};
-
-static void disable_icua_irq(struct irq_data *data)
-{
- void __iomem *ier = (void *)(IER + (data->irq >> 3));
- unsigned char val;
- val = __raw_readb(ier);
- val &= ~(1 << (data->irq & 7));
- __raw_writeb(val, ier);
-}
-
-static void enable_icua_irq(struct irq_data *data)
-{
- void __iomem *ier = (void *)(IER + (data->irq >> 3));
- unsigned char val;
- val = __raw_readb(ier);
- val |= 1 << (data->irq & 7);
- __raw_writeb(val, ier);
-}
-
-static void icua_eoi(struct irq_data *data)
-{
- __raw_writeb(0, (void *)(IR + data->irq));
-}
-
-void __init setup_rx_irq_desc(void)
-{
- int i;
-
- for (i = 16; i < 256; i++) {
- struct irq_desc *irq_desc;
-
- irq_desc = irq_alloc_desc_at(i, numa_node_id());
- if (unlikely(!irq_desc)) {
- printk(KERN_INFO "can not get irq_desc for %d\n", i);
- continue;
- }
-
- disable_irq_nosync(i);
- irq_set_chip_and_handler_name(i, &chip, handle_fasteoi_irq, "icua");
- }
- for (i = 0; i < 0x90; i++)
- __raw_writeb(1, (void __iomem *)(IPR + i));
-}
+++ /dev/null
-/*
- * Interrupt handling for RX-INTC IPR
- *
- * Copyright (C) 2010 Yoshinori Sato
- *
- */
-
-#include <linux/linkage.h>
-#include <linux/interrupt.h>
-#include <asm/io.h>
-#define IR (0x00087000)
-#define IER (0x00087200)
-
-static void disable_ipr_irq(struct irq_data *data)
-{
- void *ipr = irq_data_get_irq_chip(data);
- __raw_writeb(0, ipr);
-}
-
-static void enable_ipr_irq(struct irq_data *data)
-{
- unsigned int offset;
- unsigned int bit;
- u8 ier;
- void *ipr = irq_data_get_irq_chip(data);
- __raw_writeb(1, ipr);
- offset = data->irq / 8;
- bit = data->irq % 8;
- ier = __raw_readb((void __iomem *)(IER + offset));
- ier |= (1 << bit); /* enable IRQ on ICU */
- __raw_writeb(ier, (void __iomem *)(IER + offset));
-}
-
-const static struct {
- int irq;
- int ipr;
-} irq_info[] __initdata = {
-#if defined(CONFIG_CPU_RX610)
- { 20, 0x01}, { 22, 0x02}, /* FCU */
- { 28, 0x04}, { 29, 0x05}, { 30, 0x06}, { 31, 0x07}, /* CMT */
- { 64, 0x20}, { 65, 0x21}, { 66, 0x22}, { 67, 0x23}, /* EXT */
- { 68, 0x24}, { 69, 0x25}, { 70, 0x26}, { 71, 0x27},
- { 72, 0x28}, { 73, 0x29}, { 74, 0x2a}, { 75, 0x2b},
- { 76, 0x2c}, { 77, 0x2d}, { 78, 0x2e}, { 79, 0x2f},
- { 96, 0x40}, /* WDT */
- { 98, 0x44}, { 99, 0x45}, {100, 0x46}, {101, 0x47}, /* ADC */
- {104, 0x4c}, {105, 0x4c}, {106, 0x4c}, {107, 0x4c}, /* TPU */
- {108, 0x4d},
- {111, 0x4e}, {112, 0x4e}, {115, 0x4f}, {116, 0x4f},
- {117, 0x50}, {118, 0x50}, {120, 0x51}, {121, 0x51},
- {122, 0x52}, {123, 0x52}, {124, 0x52}, {125, 0x52},
- {126, 0x53},
- {127, 0x54}, {128, 0x54}, {131, 0x55}, {132, 0x55},
- {133, 0x56}, {134, 0x56}, {136, 0x57}, {137, 0x57},
- {138, 0x58}, {139, 0x58}, {140, 0x58}, {141, 0x58},
- {142, 0x59},
- {145, 0x5a}, {146, 0x5a}, {149, 0x5b}, {150, 0x5b},
- {151, 0x5c}, {152, 0x5c}, {154, 0x5d}, {155, 0x5d},
- {156, 0x5e}, {157, 0x5e}, {158, 0x5e}, {159, 0x5e},
- {160, 0x5f},
- {161, 0x60}, {162, 0x60}, {165, 0x61}, {166, 0x61},
- {167, 0x62}, {168, 0x62}, {170, 0x63}, {171, 0x63},
- {174, 0x68}, {175, 0x68}, {176, 0x68}, /* TMR */
- {177, 0x69}, {178, 0x69}, {179, 0x69},
- {180, 0x6a}, {181, 0x6a}, {182, 0x6a},
- {183, 0x6b}, {184, 0x6b}, {185, 0x6b},
- {198, 0x70}, {199, 0x71}, {200, 0x72}, {201, 0x73}, /* DMA */
- {214, 0x80}, {215, 0x80}, {216, 0x80}, {217, 0x80}, /* SCI */
- {218, 0x81}, {219, 0x81}, {220, 0x81}, {221, 0x81},
- {222, 0x82}, {223, 0x82}, {224, 0x82}, {225, 0x82},
- {226, 0x83}, {227, 0x83}, {228, 0x83}, {229, 0x83},
- {230, 0x84}, {231, 0x84}, {232, 0x84}, {233, 0x84},
- {234, 0x85}, {235, 0x85}, {236, 0x85}, {237, 0x85},
- {238, 0x86}, {239, 0x86}, {240, 0x86}, {241, 0x86},
- {246, 0x88}, {247, 0x89}, {248, 0x8a}, {249, 0x8b}, /* RIIC */
- {250, 0x8c}, {251, 0x8d}, {252, 0x8e}, {253, 0x8f},
-#endif
-#if defined(CONFIG_CPU_RX62N)
- { 20, 0x01}, { 22, 0x02}, /* FCU */
- { 28, 0x04}, { 29, 0x05}, { 30, 0x06}, { 31, 0x07}, /* CMT */
- { 32, 0x08}, /* EINT */
- { 36, 0x0c}, { 37, 0x0d}, { 38, 0x0e}, /* USB */
- { 40, 0x10}, { 41, 0x11}, { 42, 0x12},
- { 44, 0x14}, { 45, 0x14}, { 46, 0x14}, { 47, 0x14}, /* RSPI0 */
- { 48, 0x15}, { 49, 0x15}, { 50, 0x15}, { 51, 0x15},
- { 56, 0x18}, { 57, 0x18}, { 58, 0x18}, { 59, 0x18}, { 60, 0x18}, /* CAN */
- { 62, 0x1e}, { 63, 0x1f}, /* RTC */
- { 64, 0x20}, { 65, 0x21}, { 66, 0x22}, { 67, 0x23}, /* EXT */
- { 68, 0x24}, { 69, 0x25}, { 70, 0x26}, { 71, 0x27},
- { 72, 0x28}, { 73, 0x29}, { 74, 0x2a}, { 75, 0x2b},
- { 76, 0x2c}, { 77, 0x2d}, { 78, 0x2e}, { 79, 0x2f},
- { 90, 0x3a}, { 91, 0x3b}, /* USB */
- { 92, 0x3c}, /* RTC */
- { 96, 0x40}, /* WDT */
- { 98, 0x44}, { 99, 0x45}, {102, 0x48}, /* ADC */
- {114, 0x51}, {115, 0x51}, {116, 0x51}, {117, 0x51}, /* MTU */
- {118, 0x52}, {119, 0x52}, {120, 0x52},
- {121, 0x53}, {122, 0x53}, {123, 0x54}, {124, 0x54},
- {125, 0x55}, {126, 0x55}, {127, 0x56}, {128, 0x56},
- {129, 0x57}, {130, 0x57}, {131, 0x57}, {132, 0x57}, {133, 0x58},
- {134, 0x59}, {135, 0x59}, {136, 0x59}, {137, 0x59}, {138, 0x5a},
- {139, 0x5b}, {140, 0x5b}, {141, 0x5b},
- {142, 0x5c}, {143, 0x5c}, {144, 0x5c}, {145, 0x5c},
- {146, 0x5d}, {147, 0x5d}, {148, 0x5d},
- {149, 0x5e}, {150, 0x5e}, {151, 0x5f}, {152, 0x5f},
- {153, 0x60}, {154, 0x60}, {155, 0x61}, {156, 0x61},
- {157, 0x62}, {158, 0x62}, {159, 0x62}, {160, 0x62}, {161, 0x63},
- {162, 0x64}, {163, 0x64}, {164, 0x64}, {165, 0x64}, {166, 0x65},
- {167, 0x66}, {168, 0x66}, {169, 0x66},
- {170, 0x67}, {171, 0x67}, {172, 0x67}, {173, 0x67}, /* POE */
- {174, 0x68}, {175, 0x68}, {176, 0x68}, /* TMR */
- {177, 0x69}, {178, 0x69}, {179, 0x69},
- {180, 0x6a}, {181, 0x6a}, {182, 0x6a},
- {183, 0x6b}, {184, 0x6b}, {185, 0x6b},
- {198, 0x70}, {199, 0x71}, {200, 0x72}, {201, 0x73}, /* DMAC */
- {202, 0x74}, {203, 0x75}, /* EXDMA */
- {214, 0x80}, {215, 0x80}, {216, 0x80}, {217, 0x80}, /* SCI */
- {218, 0x81}, {219, 0x81}, {220, 0x81}, {221, 0x81},
- {222, 0x82}, {223, 0x82}, {224, 0x82}, {225, 0x82},
- {226, 0x83}, {227, 0x83}, {228, 0x83}, {229, 0x83},
- {234, 0x85}, {235, 0x85}, {236, 0x85}, {237, 0x85},
- {238, 0x86}, {239, 0x86}, {240, 0x86}, {241, 0x86},
- {246, 0x88}, {247, 0x89}, {248, 0x8a}, {249, 0x8b}, /* RIIC */
- {250, 0x8c}, {251, 0x8d}, {252, 0x8e}, {253, 0x8f},
-#endif
-};
-
-struct irq_chip chip = {
- .name = "RX-IPR",
- .irq_mask = disable_ipr_irq,
- .irq_unmask = enable_ipr_irq,
- .irq_mask_ack = disable_ipr_irq,
-};
-
-void __init setup_rx_irq_desc(void)
-{
- int i;
-
- for (i = 0; i < ARRAY_SIZE(irq_info); i++) {
- if (unlikely(!irq_alloc_desc_at(irq_info[i].irq, numa_node_id()))) {
- printk(KERN_INFO "can not get irq_desc for %d\n",
- irq_info[i].irq);
- continue;
- }
-
- disable_irq_nosync(irq_info[i].irq);
- irq_set_chip_and_handler_name(irq_info[i].irq, &chip, handle_level_irq,"");
- irq_set_chip_data(irq_info[i].irq, (void *)(0x00087300 +irq_info[i].ipr));
- disable_ipr_irq(irq_get_irq_data(irq_info[i].irq));
- }
-}
+++ /dev/null
-obj-y = setup.o clock.o
+++ /dev/null
-/*
- * RX610 CPG setup
- *
- * Copyright (C) 2009 Yoshinori Sato <ysato@users.sourceforge.jp>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-/*
- * clock diagram
- * xtal/ext clock -- *8 pll -+- div1 -- cpu core
- * |
- * +- div2 -- internal peripheral
- * |
- * +- div3 -- external bus
- */
-
-#include <linux/linkage.h>
-#include <linux/clk.h>
-#include <asm/clock.h>
-#include <asm/io.h>
-
-#define MHz 1000000
-
-/* pll output clock */
-static struct clk master = {
- .name = "master_clk",
- .flags = CLK_ENABLE_ON_INIT,
- .rate = CONFIG_INPUT_CLOCK_FREQ * 8,
- .set_rate = NULL,
- .update = NULL,
-};
-
-const int __initdata div_rate[] = {1, 2, 4, 8};
-
-static int update_clock(struct clk *clk, unsigned long rate, int bits)
-{
- unsigned long master_freq = clk_get_rate(clk->parent);
- int i;
- rate = clk_round_rate(clk, rate);
- for (i = 0; i < ARRAY_SIZE(div_rate); i++)
- if (rate == master_freq / div_rate[i]) {
- unsigned long flags;
- unsigned long sckcr;
- local_irq_save(flags);
- sckcr = __raw_readl((void *)0x00080020);
- sckcr &= ~(0x0f << bits);
- sckcr |= i << bits;
- __raw_writel(sckcr, (void *)0x00080020);
- local_irq_restore(flags);
- clk->rate = rate;
- return 0;
- }
- return 1;
-}
-
-
-static int cpu_set_rate(struct clk *clk, unsigned long rate)
-{
- if (rate > 100 * MHz)
- return 1;
- return update_clock(clk, rate, 24);
-}
-
-static int cpu_update(struct clk *clk)
-{
- return update_clock(clk, clk->rate, 24);
-}
-
-static struct clk cpu = {
- .name = "cpu_clk",
- .parent = &master,
- .flags = CLK_ENABLE_ON_INIT,
- .set_rate = cpu_set_rate,
- .update = cpu_update,
-};
-
-static int peripheral_set_rate(struct clk *clk, unsigned long rate)
-{
- if (rate > 50 * MHz)
- return 1;
- return update_clock(clk, rate, 8);
-}
-
-static int peripheral_update(struct clk *clk)
-{
- return update_clock(clk, clk->rate, 8);
-}
-
-static struct clk peripheral = {
- .name = "peripheral_clk",
- .parent = &master,
- .flags = CLK_ENABLE_ON_INIT,
- .set_rate = peripheral_set_rate,
- .update = peripheral_update,
-};
-
-static int bus_set_rate(struct clk *clk, unsigned long rate)
-{
- if (rate > 25 * MHz)
- return 1;
- return update_clock(clk, rate, 16);
-}
-
-static int bus_update(struct clk *clk)
-{
- return update_clock(clk, clk->rate, 16);
-}
-
-static struct clk bus = {
- .name = "bus_clk",
- .parent = &master,
- .flags = CLK_ENABLE_ON_INIT,
- .set_rate = bus_set_rate,
- .update = bus_update,
-};
-
-static void __init set_selectable(struct clk *clk, int limit)
-{
- int i, nr;
- for(i = ARRAY_SIZE(div_rate) - 1, nr = 0; i >= 0; i--) {
- int f = (CONFIG_INPUT_CLOCK_FREQ * 8) / div_rate[i];
- if (f > limit)
- break;
- clk->selectable[nr++] = f;
- }
- clk->nr_selectable = nr;
-}
-
-int __init arch_clk_init(void)
-{
- int ret;
- if ((ret = clk_register(&master)))
- pr_err("%s: CPU clock registration failed.\n", __func__);
-
- set_selectable(&cpu, 100 * MHz);
- if ((ret = clk_register(&cpu))) {
- pr_err("%s: CPU clock registration failed.\n", __func__);
- goto end;
- }
- set_selectable(&peripheral, 50 * MHz);
- if ((ret = clk_register(&peripheral))) {
- pr_err("%s: CPU clock registration failed.\n", __func__);
- goto end;
- }
- set_selectable(&bus, 25 * MHz);
- if ((ret = clk_register(&bus))) {
- pr_err("%s: CPU clock registration failed.\n", __func__);
- goto end;
- }
-end:
- return ret;
-}
+++ /dev/null
-/*
- * RX610 Internal peripheral setup
- *
- * Copyright (C) 2009 Yoshinori Sato <ysato@users.sourceforge.jp>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/platform_device.h>
-#include <linux/serial_sci.h>
-
-static struct plat_sci_port sci0_platform_data = {
- .flags = UPF_BOOT_AUTOCONF,
- .type = PORT_SCI,
- .scscr = SCSCR_RE | SCSCR_TE,
-};
-static struct plat_sci_port sci1_platform_data = {
- .flags = UPF_BOOT_AUTOCONF,
- .type = PORT_SCI,
- .scscr = SCSCR_RE | SCSCR_TE,
-};
-static struct plat_sci_port sci2_platform_data = {
- .flags = UPF_BOOT_AUTOCONF,
- .type = PORT_SCI,
- .scscr = SCSCR_RE | SCSCR_TE,
-};
-
-static struct resource sci0_resource[] = {
- DEFINE_RES_MEM(0x00088240, 8),
- DEFINE_RES_IRQ(214),
-};
-
-static struct resource sci1_resource[] = {
- DEFINE_RES_MEM(0x00088248, 8),
- DEFINE_RES_IRQ(218),
-};
-
-static struct resource sci2_resource[] = {
- DEFINE_RES_MEM(0x00088250, 8),
- DEFINE_RES_IRQ(222),
-};
-
-static struct platform_device sci_device[] = {
- {
- .name = "sh-sci",
- .id = 0,
- .resource = sci0_resource,
- .num_resources = ARRAY_SIZE(sci0_resource),
- .dev = {
- .platform_data = &sci0_platform_data,
- },
- },
- {
- .name = "sh-sci",
- .id = 1,
- .resource = sci1_resource,
- .num_resources = ARRAY_SIZE(sci1_resource),
- .dev = {
- .platform_data = &sci1_platform_data,
- },
- },
- {
- .name = "sh-sci",
- .id = 2,
- .resource = sci2_resource,
- .num_resources = ARRAY_SIZE(sci2_resource),
- .dev = {
- .platform_data = &sci2_platform_data,
- },
- },
-};
-
-static struct platform_device *rx62n_devices[] __initdata = {
- &sci_device[0],
- &sci_device[1],
- &sci_device[2],
-};
-
-static int __init devices_register(void)
-{
- return platform_add_devices(rx62n_devices,
- ARRAY_SIZE(rx62n_devices));
-}
-arch_initcall(devices_register);
-
-void __init early_device_register(void)
-{
- early_platform_add_devices(rx62n_devices,
- ARRAY_SIZE(rx62n_devices));
-}
+++ /dev/null
-obj-y = setup.o clock.o
+++ /dev/null
-/*
- * RX62N CPG setup
- *
- * Copyright (C) 2011 Yoshinori Sato <ysato@users.sourceforge.jp>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-/*
- * clock diagram
- * xtal/ext clock -- *8 pll -+- div1 -- cpu core
- * |
- * +- div2 -- internal peripheral
- * |
- * +- div3 -- external bus
- */
-
-#include <linux/linkage.h>
-#include <linux/clk.h>
-#include <asm/clock.h>
-#include <asm/io.h>
-
-#define MHz 1000000
-
-/* pll output clock */
-static struct clk master = {
- .name = "master_clk",
- .flags = CLK_ENABLE_ON_INIT,
- .rate = CONFIG_INPUT_CLOCK_FREQ * 8,
- .set_rate = NULL,
-};
-
-const int __initdata div_rate[] = {8, 4, 2, 1};
-
-static int update_clock(struct clk *clk, unsigned long rate, int bits)
-{
- unsigned long master_freq = clk_get_rate(clk->parent);
- int i;
- rate = clk_round_rate(clk, rate);
- for (i = 0; i < ARRAY_SIZE(div_rate); i++)
- if (rate == master_freq / div_rate[i]) {
- unsigned long flags;
- unsigned long sckcr;
- local_irq_save(flags);
- sckcr = __raw_readl((void *)0x00080020);
- sckcr &= ~(0x0f << bits);
- sckcr |= i << bits;
- __raw_writel(sckcr, (void *)0x00080020);
- local_irq_restore(flags);
- clk->rate = rate;
- return 0;
- }
- return 1;
-}
-
-
-static int cpu_set_rate(struct clk *clk, unsigned long rate)
-{
- if (rate > 100 * MHz)
- return 1;
- return update_clock(clk, rate, 24);
-}
-
-static int cpu_update(struct clk *clk)
-{
- return update_clock(clk, clk->rate, 24);
-}
-
-static struct clk cpu = {
- .name = "cpu_clk",
- .parent = &master,
- .flags = CLK_ENABLE_ON_INIT,
- .set_rate = cpu_set_rate,
-};
-
-static int peripheral_set_rate(struct clk *clk, unsigned long rate)
-{
- if (rate > 50 * MHz)
- return 1;
- return update_clock(clk, rate, 8);
-}
-
-static int peripheral_update(struct clk *clk)
-{
- return update_clock(clk, clk->rate, 8);
-}
-
-static struct clk peripheral = {
- .name = "peripheral_clk",
- .parent = &master,
- .flags = CLK_ENABLE_ON_INIT,
- .set_rate = peripheral_set_rate,
-};
-
-static int bus_set_rate(struct clk *clk, unsigned long rate)
-{
- if (rate > 50 * MHz)
- return 1;
- return update_clock(clk, rate, 16);
-}
-
-static int bus_update(struct clk *clk)
-{
- return update_clock(clk, clk->rate, 16);
-}
-
-static struct clk bus = {
- .name = "bus_clk",
- .parent = &master,
- .flags = CLK_ENABLE_ON_INIT,
- .set_rate = bus_set_rate,
-};
-
-static void __init set_selectable(struct clk *clk, int limit)
-{
- int i, nr, max;
- for(i = 0, nr = 0, max = 0; i < ARRAY_SIZE(div_rate); i++) {
- int f = (CONFIG_INPUT_CLOCK_FREQ * 8) / div_rate[i];
- if (f <= limit) {
- if (f > max) {
- clk->nr_selectable = nr;
- max = f;
- }
- clk->selectable[nr++] = f;
- }
- }
-}
-
-static void __init set_clock_nr(struct clk *clk, int freq)
-{
- int i;
- for (i = 0; i < DIV_NR; i++)
- if (clk->selectable[i] == freq) {
- clk->nr_selectable = i;
- break;
- }
-}
-
-int __init arch_clk_init(void)
-{
- int ret;
- if ((ret = clk_register(&master)))
- pr_err("%s: CPU clock registration failed.\n", __func__);
-
- set_selectable(&cpu, 100 * MHz);
- if ((ret = clk_register(&cpu))) {
- pr_err("%s: CPU clock registration failed.\n", __func__);
- goto end;
- }
- set_selectable(&peripheral, 50 * MHz);
- set_clock_nr(&peripheral, CONFIG_INPUT_CLOCK_FREQ * CONFIG_PCLK_MULT);
- if ((ret = clk_register(&peripheral))) {
- pr_err("%s: CPU clock registration failed.\n", __func__);
- goto end;
- }
- set_selectable(&bus, 50 * MHz);
- if ((ret = clk_register(&bus))) {
- pr_err("%s: CPU clock registration failed.\n", __func__);
- goto end;
- }
-end:
- return ret;
-}
+++ /dev/null
-/*
- * RX62N Internal peripheral setup
- *
- * Copyright (C) 2011 Yoshinori Sato <ysato@users.sourceforge.jp>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/platform_device.h>
-#include <linux/serial_sci.h>
-
-static struct plat_sci_port sci_platform_data[] = {
- /* SCI0 to SCI1 */
- {
- .mapbase = 0x00088240,
- .flags = UPF_BOOT_AUTOCONF,
- .type = PORT_SCI,
- .scscr = SCSCR_RE | SCSCR_TE,
- .scbrr_algo_id = -1,
- .irqs = { 214, 215, 216, 0 },
- }, {
- .mapbase = 0x00088248,
- .flags = UPF_BOOT_AUTOCONF,
- .type = PORT_SCI,
- .scscr = SCSCR_RE | SCSCR_TE,
- .scbrr_algo_id = -1,
- .irqs = { 218, 219, 220, 0 },
- }, {
- .flags = 0,
- }
-};
-
-static struct platform_device sci_device[] = {
- {
- .name = "sh-sci",
- .id = 0,
- .dev = {
- .platform_data = &sci_platform_data[0],
- },
- },
- {
- .name = "sh-sci",
- .id = 1,
- .dev = {
- .platform_data = &sci_platform_data[1],
- },
- },
-};
-
-static struct platform_device *rx62n_devices[] __initdata = {
- &sci_device[0],
- &sci_device[1],
-};
-
-static int __init devices_register(void)
-{
- return platform_add_devices(rx62n_devices,
- ARRAY_SIZE(rx62n_devices));
-}
-arch_initcall(devices_register);
-
-void __init early_device_register(void)
-{
- early_platform_add_devices(rx62n_devices,
- ARRAY_SIZE(rx62n_devices));
- *(volatile unsigned long *)0x00080010 &= ~0x00008000;
-}
+++ /dev/null
-obj-y = setup.o clock.o
+++ /dev/null
-/*
- * RX62N CPG setup
- *
- * Copyright (C) 2011 Yoshinori Sato <ysato@users.sourceforge.jp>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-/*
- * clock diagram
- * xtal/ext clock -- *8 pll -+- div1 -- cpu core
- * |
- * +- div2 -- internal peripheral
- * |
- * +- div3 -- external bus
- */
-
-#include <linux/linkage.h>
-#include <linux/clk.h>
-#include <asm/clock.h>
-#include <asm/io.h>
-
-#define MHz 1000000
-
-/* pll output clock */
-static struct clk master = {
- .name = "master_clk",
- .flags = CLK_ENABLE_ON_INIT,
- .rate = CONFIG_INPUT_CLOCK_FREQ * 8,
- .set_rate = NULL,
-};
-
-const int __initdata div_rate[] = {8, 4, 2, 1};
-
-static int update_clock(struct clk *clk, unsigned long rate, int bits)
-{
- unsigned long master_freq = clk_get_rate(clk->parent);
- int i;
- rate = clk_round_rate(clk, rate);
- for (i = 0; i < ARRAY_SIZE(div_rate); i++)
- if (rate == master_freq / div_rate[i]) {
- unsigned long flags;
- unsigned long sckcr;
- local_irq_save(flags);
- sckcr = __raw_readl((void *)0x00080020);
- sckcr &= ~(0x0f << bits);
- sckcr |= i << bits;
- __raw_writel(sckcr, (void *)0x00080020);
- local_irq_restore(flags);
- clk->rate = rate;
- return 0;
- }
- return 1;
-}
-
-
-static int cpu_set_rate(struct clk *clk, unsigned long rate)
-{
- if (rate > 100 * MHz)
- return 1;
- return update_clock(clk, rate, 24);
-}
-
-static int cpu_update(struct clk *clk)
-{
- return update_clock(clk, clk->rate, 24);
-}
-
-static struct clk cpu = {
- .name = "cpu_clk",
- .parent = &master,
- .flags = CLK_ENABLE_ON_INIT,
- .set_rate = cpu_set_rate,
-};
-
-static int peripheral_set_rate(struct clk *clk, unsigned long rate)
-{
- if (rate > 50 * MHz)
- return 1;
- return update_clock(clk, rate, 8);
-}
-
-static int peripheral_update(struct clk *clk)
-{
- return update_clock(clk, clk->rate, 8);
-}
-
-static struct clk peripheral = {
- .name = "peripheral_clk",
- .parent = &master,
- .flags = CLK_ENABLE_ON_INIT,
- .set_rate = peripheral_set_rate,
-};
-
-static int bus_set_rate(struct clk *clk, unsigned long rate)
-{
- if (rate > 50 * MHz)
- return 1;
- return update_clock(clk, rate, 16);
-}
-
-static int bus_update(struct clk *clk)
-{
- return update_clock(clk, clk->rate, 16);
-}
-
-static struct clk bus = {
- .name = "bus_clk",
- .parent = &master,
- .flags = CLK_ENABLE_ON_INIT,
- .set_rate = bus_set_rate,
-};
-
-static void __init set_selectable(struct clk *clk, int limit)
-{
- int i, nr, max;
- for(i = 0, nr = 0, max = 0; i < ARRAY_SIZE(div_rate); i++) {
- int f = (CONFIG_INPUT_CLOCK_FREQ * 8) / div_rate[i];
- if (f <= limit) {
- if (f > max) {
- clk->nr_selectable = nr;
- max = f;
- }
- clk->selectable[nr++] = f;
- }
- }
-}
-
-static void __init set_clock_nr(struct clk *clk, int freq)
-{
- int i;
- for (i = 0; i < DIV_NR; i++)
- if (clk->selectable[i] == freq) {
- clk->nr_selectable = i;
- break;
- }
-}
-
-int __init arch_clk_init(void)
-{
- int ret;
- if ((ret = clk_register(&master)))
- pr_err("%s: CPU clock registration failed.\n", __func__);
-
- set_selectable(&cpu, 100 * MHz);
- if ((ret = clk_register(&cpu))) {
- pr_err("%s: CPU clock registration failed.\n", __func__);
- goto end;
- }
- set_selectable(&peripheral, 50 * MHz);
- set_clock_nr(&peripheral, CONFIG_INPUT_CLOCK_FREQ * CONFIG_PCLK_MULT);
- if ((ret = clk_register(&peripheral))) {
- pr_err("%s: CPU clock registration failed.\n", __func__);
- goto end;
- }
- set_selectable(&bus, 50 * MHz);
- if ((ret = clk_register(&bus))) {
- pr_err("%s: CPU clock registration failed.\n", __func__);
- goto end;
- }
-end:
- return ret;
-}
+++ /dev/null
-/*
- * RX62N Internal peripheral setup
- *
- * Copyright (C) 2011 Yoshinori Sato <ysato@users.sourceforge.jp>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/platform_device.h>
-#include <linux/serial_sci.h>
-
-static struct plat_sci_port sci_platform_data[] = {
- /* SCIF0 to SCIF3 */
- {
- .mapbase = 0x000d0000,
- .flags = UPF_BOOT_AUTOCONF,
- .type = PORT_RXSCIF,
- .scscr = SCSCR_RE | SCSCR_TE,
- .scbrr_algo_id = -1,
- .irqs = { 100, 101, 0, 0 },
- }, {
- .mapbase = 0x000d0020,
- .flags = UPF_BOOT_AUTOCONF,
- .type = PORT_RXSCIF,
- .scscr = SCSCR_RE | SCSCR_TE,
- .scbrr_algo_id = -1,
- .irqs = { 102, 103, 0, 0 },
- }, {
- .mapbase = 0x000d0040,
- .flags = UPF_BOOT_AUTOCONF,
- .type = PORT_RXSCIF,
- .scscr = SCSCR_RE | SCSCR_TE,
- .scbrr_algo_id = -1,
- .irqs = { 104, 105, 0, 0 },
- }, {
- .mapbase = 0x000d0060,
- .flags = UPF_BOOT_AUTOCONF,
- .type = PORT_RXSCIF,
- .scscr = SCSCR_RE | SCSCR_TE,
- .scbrr_algo_id = -1,
- .irqs = { 114, 115, 0, 0 },
- }, {
- .flags = 0,
- }
-};
-
-static struct platform_device sci_device[] = {
- {
- .name = "sh-sci",
- .id = 0,
- .dev = {
- .platform_data = &sci_platform_data[0],
- },
- },
- {
- .name = "sh-sci",
- .id = 1,
- .dev = {
- .platform_data = &sci_platform_data[1],
- },
- },
- {
- .name = "sh-sci",
- .id = 2,
- .dev = {
- .platform_data = &sci_platform_data[2],
- },
- },
- {
- .name = "sh-sci",
- .id = 3,
- .dev = {
- .platform_data = &sci_platform_data[3],
- },
- },
-};
-
-static struct platform_device *rx64m_devices[] __initdata = {
- &sci_device[0],
- &sci_device[1],
- &sci_device[2],
- &sci_device[3],
-};
-
-static int __init devices_register(void)
-{
- return platform_add_devices(rx64m_devices,
- ARRAY_SIZE(rx64m_devices));
-}
-arch_initcall(devices_register);
-
-void __init early_device_register(void)
-{
- early_platform_add_devices(rx64m_devices,
- ARRAY_SIZE(rx64m_devices));
- *(volatile unsigned long *)0x00080010 &= ~0x00008000;
-}