Skip to content

Commit

Permalink
Merge branches 'sh/hwblk', 'sh/cpuidle' and 'sh/stable-updates'
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Mundt committed Jul 4, 2009
3 parents 4048e5c + 7426394 + 9731f4a commit 1ecc6ab
Show file tree
Hide file tree
Showing 33 changed files with 1,315 additions and 613 deletions.
38 changes: 38 additions & 0 deletions arch/sh/boards/mach-se/7724/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <linux/smc91x.h>
#include <linux/gpio.h>
#include <linux/input.h>
#include <linux/usb/r8a66597.h>
#include <video/sh_mobile_lcdc.h>
#include <media/sh_mobile_ceu.h>
#include <asm/io.h>
Expand Down Expand Up @@ -302,6 +303,34 @@ static struct platform_device sh_eth_device = {
.resource = sh_eth_resources,
};

static struct r8a66597_platdata sh7724_usb0_host_data = {
};

static struct resource sh7724_usb0_host_resources[] = {
[0] = {
.start = 0xa4d80000,
.end = 0xa4d800ff,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = 65,
.end = 65,
.flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
},
};

static struct platform_device sh7724_usb0_host_device = {
.name = "r8a66597_hcd",
.id = 0,
.dev = {
.dma_mask = NULL, /* not use dma */
.coherent_dma_mask = 0xffffffff,
.platform_data = &sh7724_usb0_host_data,
},
.num_resources = ARRAY_SIZE(sh7724_usb0_host_resources),
.resource = sh7724_usb0_host_resources,
};

static struct platform_device *ms7724se_devices[] __initdata = {
&heartbeat_device,
&smc91x_eth_device,
Expand All @@ -311,6 +340,7 @@ static struct platform_device *ms7724se_devices[] __initdata = {
&ceu1_device,
&keysc_device,
&sh_eth_device,
&sh7724_usb0_host_device,
};

#define EEPROM_OP 0xBA206000
Expand Down Expand Up @@ -364,6 +394,7 @@ static void __init sh_eth_init(void)
#define SW4140 0xBA201000
#define FPGA_OUT 0xBA200400
#define PORT_HIZA 0xA4050158
#define PORT_MSELCRB 0xA4050182

#define SW41_A 0x0100
#define SW41_B 0x0200
Expand All @@ -373,6 +404,7 @@ static void __init sh_eth_init(void)
#define SW41_F 0x2000
#define SW41_G 0x4000
#define SW41_H 0x8000

static int __init devices_setup(void)
{
u16 sw = ctrl_inw(SW4140); /* select camera, monitor */
Expand All @@ -385,6 +417,12 @@ static int __init devices_setup(void)
(1 << 14)), /* RMII */
FPGA_OUT);

/* turn on USB clocks, use external clock */
ctrl_outw((ctrl_inw(PORT_MSELCRB) & ~0xc000) | 0x8000, PORT_MSELCRB);

/* enable USB0 port */
ctrl_outw(0x0600, 0xa40501d4);

/* enable IRQ 0,1,2 */
gpio_request(GPIO_FN_INTC_IRQ0, NULL);
gpio_request(GPIO_FN_INTC_IRQ1, NULL);
Expand Down
61 changes: 61 additions & 0 deletions arch/sh/include/asm/hwblk.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#ifndef __ASM_SH_HWBLK_H
#define __ASM_SH_HWBLK_H

#include <asm/clock.h>
#include <asm/io.h>

#define HWBLK_AREA_FLAG_PARENT (1 << 0) /* valid parent */

#define HWBLK_AREA(_flags, _parent) \
{ \
.flags = _flags, \
.parent = _parent, \
}

struct hwblk_area {
unsigned long cnt;
unsigned char parent;
unsigned char flags;
};

#define HWBLK(_mstp, _bit, _area) \
{ \
.mstp = (void __iomem *)_mstp, \
.bit = _bit, \
.area = _area, \
}

struct hwblk {
void __iomem *mstp;
unsigned char bit;
unsigned char area;
unsigned long cnt;
};

struct hwblk_info {
struct hwblk_area *areas;
int nr_areas;
struct hwblk *hwblks;
int nr_hwblks;
};

/* Should be defined by processor-specific code */
int arch_hwblk_init(void);
int arch_hwblk_sleep_mode(void);

int hwblk_register(struct hwblk_info *info);
int hwblk_init(void);

/* allow clocks to enable and disable hardware blocks */
#define SH_HWBLK_CLK(_name, _id, _parent, _hwblk, _flags) \
{ \
.name = _name, \
.id = _id, \
.parent = _parent, \
.arch_flags = _hwblk, \
.flags = _flags, \
}

int sh_hwblk_clk_register(struct clk *clks, int nr);

#endif /* __ASM_SH_HWBLK_H */
9 changes: 9 additions & 0 deletions arch/sh/include/asm/suspend.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ struct swsusp_arch_regs {
struct pt_regs user_regs;
unsigned long bank1_regs[8];
};

void sh_mobile_call_standby(unsigned long mode);

#ifdef CONFIG_CPU_IDLE
void sh_mobile_setup_cpuidle(void);
#else
static inline void sh_mobile_setup_cpuidle(void) {}
#endif

#endif

/* flags passed to assembly suspend code */
Expand Down
14 changes: 14 additions & 0 deletions arch/sh/include/cpu-sh4/cpu/sh7722.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,18 @@ enum {
GPIO_FN_KEYOUT3, GPIO_FN_KEYOUT4_IN6, GPIO_FN_KEYOUT5_IN5,
};

enum {
HWBLK_UNKNOWN = 0,
HWBLK_TLB, HWBLK_IC, HWBLK_OC, HWBLK_URAM, HWBLK_XYMEM,
HWBLK_INTC, HWBLK_DMAC, HWBLK_SHYWAY, HWBLK_HUDI,
HWBLK_UBC, HWBLK_TMU, HWBLK_CMT, HWBLK_RWDT, HWBLK_FLCTL,
HWBLK_SCIF0, HWBLK_SCIF1, HWBLK_SCIF2, HWBLK_SIO,
HWBLK_SIOF0, HWBLK_SIOF1, HWBLK_IIC, HWBLK_RTC,
HWBLK_TPU, HWBLK_IRDA, HWBLK_SDHI, HWBLK_SIM, HWBLK_KEYSC,
HWBLK_TSIF, HWBLK_USBF, HWBLK_2DG, HWBLK_SIU, HWBLK_VOU,
HWBLK_JPU, HWBLK_BEU, HWBLK_CEU, HWBLK_VEU, HWBLK_VPU,
HWBLK_LCDC,
HWBLK_NR,
};

#endif /* __ASM_SH7722_H__ */
2 changes: 1 addition & 1 deletion arch/sh/kernel/cpu/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ obj-$(CONFIG_UBC_WAKEUP) += ubc.o
obj-$(CONFIG_SH_ADC) += adc.o
obj-$(CONFIG_SH_CLK_CPG) += clock-cpg.o

obj-y += irq/ init.o clock.o
obj-y += irq/ init.o clock.o hwblk.o
130 changes: 130 additions & 0 deletions arch/sh/kernel/cpu/hwblk.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#include <linux/clk.h>
#include <linux/compiler.h>
#include <linux/slab.h>
#include <linux/io.h>
#include <linux/spinlock.h>
#include <asm/suspend.h>
#include <asm/hwblk.h>
#include <asm/clock.h>

static DEFINE_SPINLOCK(hwblk_lock);

static void hwblk_area_inc(struct hwblk_info *info, int area)
{
struct hwblk_area *hap = info->areas + area;

hap->cnt++;
if (hap->cnt == 1)
if (hap->flags & HWBLK_AREA_FLAG_PARENT)
hwblk_area_inc(info, hap->parent);
}

static void hwblk_area_dec(struct hwblk_info *info, int area)
{
struct hwblk_area *hap = info->areas + area;

if (hap->cnt == 1)
if (hap->flags & HWBLK_AREA_FLAG_PARENT)
hwblk_area_dec(info, hap->parent);
hap->cnt--;
}

static void hwblk_enable(struct hwblk_info *info, int hwblk)
{
struct hwblk *hp = info->hwblks + hwblk;
unsigned long tmp;
unsigned long flags;

spin_lock_irqsave(&hwblk_lock, flags);

hp->cnt++;
if (hp->cnt == 1) {
hwblk_area_inc(info, hp->area);

tmp = __raw_readl(hp->mstp);
tmp &= ~(1 << hp->bit);
__raw_writel(tmp, hp->mstp);
}

spin_unlock_irqrestore(&hwblk_lock, flags);
}

static void hwblk_disable(struct hwblk_info *info, int hwblk)
{
struct hwblk *hp = info->hwblks + hwblk;
unsigned long tmp;
unsigned long flags;

spin_lock_irqsave(&hwblk_lock, flags);

if (hp->cnt == 1) {
hwblk_area_dec(info, hp->area);

tmp = __raw_readl(hp->mstp);
tmp |= 1 << hp->bit;
__raw_writel(tmp, hp->mstp);
}
hp->cnt--;

spin_unlock_irqrestore(&hwblk_lock, flags);
}

static struct hwblk_info *hwblk_info;

int __init hwblk_register(struct hwblk_info *info)
{
hwblk_info = info;
return 0;
}

int __init __weak arch_hwblk_init(void)
{
return 0;
}

int __weak arch_hwblk_sleep_mode(void)
{
return SUSP_SH_SLEEP;
}

int __init hwblk_init(void)
{
return arch_hwblk_init();
}

/* allow clocks to enable and disable hardware blocks */
static int sh_hwblk_clk_enable(struct clk *clk)
{
if (!hwblk_info)
return -ENOENT;

hwblk_enable(hwblk_info, clk->arch_flags);
return 0;
}

static void sh_hwblk_clk_disable(struct clk *clk)
{
if (hwblk_info)
hwblk_disable(hwblk_info, clk->arch_flags);
}

static struct clk_ops sh_hwblk_clk_ops = {
.enable = sh_hwblk_clk_enable,
.disable = sh_hwblk_clk_disable,
.recalc = followparent_recalc,
};

int __init sh_hwblk_clk_register(struct clk *clks, int nr)
{
struct clk *clkp;
int ret = 0;
int k;

for (k = 0; !ret && (k < nr); k++) {
clkp = clks + k;
clkp->ops = &sh_hwblk_clk_ops;
ret |= clk_register(clkp);
}

return ret;
}
2 changes: 1 addition & 1 deletion arch/sh/kernel/cpu/sh4a/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ clock-$(CONFIG_CPU_SUBTYPE_SH7780) := clock-sh7780.o
clock-$(CONFIG_CPU_SUBTYPE_SH7785) := clock-sh7785.o
clock-$(CONFIG_CPU_SUBTYPE_SH7786) := clock-sh7786.o
clock-$(CONFIG_CPU_SUBTYPE_SH7343) := clock-sh7343.o
clock-$(CONFIG_CPU_SUBTYPE_SH7722) := clock-sh7722.o
clock-$(CONFIG_CPU_SUBTYPE_SH7722) := clock-sh7722.o hwblk-sh7722.o
clock-$(CONFIG_CPU_SUBTYPE_SH7723) := clock-sh7723.o
clock-$(CONFIG_CPU_SUBTYPE_SH7724) := clock-sh7724.o
clock-$(CONFIG_CPU_SUBTYPE_SH7366) := clock-sh7366.o
Expand Down
Loading

0 comments on commit 1ecc6ab

Please sign in to comment.