Skip to content

Commit

Permalink
Merge tag 'v3.18-rockchip-clk2' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/mmind/linux-rockchip into clk-next

Allow parent rate changes for i2s on rk3288
and rockchip as well as s3c24xx restart handlers.
  • Loading branch information
Mike Turquette committed Oct 1, 2014
2 parents e156ee5 + e317c19 commit a797900
Show file tree
Hide file tree
Showing 14 changed files with 247 additions and 46 deletions.
12 changes: 5 additions & 7 deletions arch/arm/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,13 @@ void soft_restart(unsigned long addr)
BUG();
}

static void null_restart(enum reboot_mode reboot_mode, const char *cmd)
{
}

/*
* Function pointers to optional machine specific functions
*/
void (*pm_power_off)(void);
EXPORT_SYMBOL(pm_power_off);

void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd) = null_restart;
EXPORT_SYMBOL_GPL(arm_pm_restart);
void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);

/*
* This is our default idle handler.
Expand Down Expand Up @@ -230,7 +225,10 @@ void machine_restart(char *cmd)
local_irq_disable();
smp_send_stop();

arm_pm_restart(reboot_mode, cmd);
if (arm_pm_restart)
arm_pm_restart(reboot_mode, cmd);
else
do_kernel_restart(cmd);

/* Give a grace period for failure to restart of 1s */
mdelay(1000);
Expand Down
3 changes: 2 additions & 1 deletion arch/arm64/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ void (*pm_power_off)(void);
EXPORT_SYMBOL_GPL(pm_power_off);

void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
EXPORT_SYMBOL_GPL(arm_pm_restart);

/*
* This is our default idle handler.
Expand Down Expand Up @@ -180,6 +179,8 @@ void machine_restart(char *cmd)
/* Now call the architecture specific reboot code. */
if (arm_pm_restart)
arm_pm_restart(reboot_mode, cmd);
else
do_kernel_restart(cmd);

/*
* Whoops - the architecture was unable to reboot.
Expand Down
2 changes: 2 additions & 0 deletions drivers/clk/rockchip/clk-rk3188.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,8 @@ static void __init rk3188_common_clk_init(struct device_node *np)

rockchip_register_softrst(np, 9, reg_base + RK2928_SOFTRST_CON(0),
ROCKCHIP_SOFTRST_HIWORD_MASK);

rockchip_register_restart_notifier(RK2928_GLB_SRST_FST);
}

static void __init rk3066a_clk_init(struct device_node *np)
Expand Down
10 changes: 6 additions & 4 deletions drivers/clk/rockchip/clk-rk3288.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,15 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {
COMPOSITE(0, "i2s_src", mux_pll_src_cpll_gpll_p, 0,
RK3288_CLKSEL_CON(4), 15, 1, MFLAGS, 0, 7, DFLAGS,
RK3288_CLKGATE_CON(4), 1, GFLAGS),
COMPOSITE_FRAC(0, "i2s_frac", "i2s_src", 0,
COMPOSITE_FRAC(0, "i2s_frac", "i2s_src", CLK_SET_RATE_PARENT,
RK3288_CLKSEL_CON(8), 0,
RK3288_CLKGATE_CON(4), 2, GFLAGS),
MUX(0, "i2s_pre", mux_i2s_pre_p, 0,
MUX(0, "i2s_pre", mux_i2s_pre_p, CLK_SET_RATE_PARENT,
RK3288_CLKSEL_CON(4), 8, 2, MFLAGS),
COMPOSITE_NODIV(0, "i2s0_clkout", mux_i2s_clkout_p, 0,
COMPOSITE_NODIV(0, "i2s0_clkout", mux_i2s_clkout_p, CLK_SET_RATE_PARENT,
RK3288_CLKSEL_CON(4), 12, 1, MFLAGS,
RK3288_CLKGATE_CON(4), 0, GFLAGS),
GATE(SCLK_I2S0, "sclk_i2s0", "i2s_pre", 0,
GATE(SCLK_I2S0, "sclk_i2s0", "i2s_pre", CLK_SET_RATE_PARENT,
RK3288_CLKGATE_CON(4), 3, GFLAGS),

MUX(0, "spdif_src", mux_pll_src_cpll_gpll_p, 0,
Expand Down Expand Up @@ -808,5 +808,7 @@ static void __init rk3288_clk_init(struct device_node *np)

rockchip_register_softrst(np, 12, reg_base + RK3288_SOFTRST_CON(0),
ROCKCHIP_SOFTRST_HIWORD_MASK);

rockchip_register_restart_notifier(RK3288_GLB_SRST_FST);
}
CLK_OF_DECLARE(rk3288_cru, "rockchip,rk3288-cru", rk3288_clk_init);
25 changes: 25 additions & 0 deletions drivers/clk/rockchip/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <linux/clk-provider.h>
#include <linux/mfd/syscon.h>
#include <linux/regmap.h>
#include <linux/reboot.h>
#include "clk.h"

/**
Expand Down Expand Up @@ -330,3 +331,27 @@ void __init rockchip_clk_protect_critical(const char *clocks[], int nclocks)
clk_prepare_enable(clk);
}
}

static unsigned int reg_restart;
static int rockchip_restart_notify(struct notifier_block *this,
unsigned long mode, void *cmd)
{
writel(0xfdb9, reg_base + reg_restart);
return NOTIFY_DONE;
}

static struct notifier_block rockchip_restart_handler = {
.notifier_call = rockchip_restart_notify,
.priority = 128,
};

void __init rockchip_register_restart_notifier(unsigned int reg)
{
int ret;

reg_restart = reg;
ret = register_restart_handler(&rockchip_restart_handler);
if (ret)
pr_err("%s: cannot register restart handler, %d\n",
__func__, ret);
}
1 change: 1 addition & 0 deletions drivers/clk/rockchip/clk.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ void rockchip_clk_register_armclk(unsigned int lookup_id, const char *name,
const struct rockchip_cpuclk_rate_table *rates,
int nrates);
void rockchip_clk_protect_critical(const char *clocks[], int nclocks);
void rockchip_register_restart_notifier(unsigned int reg);

#define ROCKCHIP_SOFTRST_HIWORD_MASK BIT(0)

Expand Down
29 changes: 29 additions & 0 deletions drivers/clk/samsung/clk-s3c2412.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/syscore_ops.h>
#include <linux/reboot.h>

#include <dt-bindings/clock/s3c2412.h>

Expand All @@ -26,6 +27,7 @@
#define CLKCON 0x0c
#define CLKDIVN 0x14
#define CLKSRC 0x1c
#define SWRST 0x30

/* list of PLLs to be registered */
enum s3c2412_plls {
Expand Down Expand Up @@ -204,6 +206,28 @@ struct samsung_clock_alias s3c2412_aliases[] __initdata = {
ALIAS(MSYSCLK, NULL, "fclk"),
};

static int s3c2412_restart(struct notifier_block *this,
unsigned long mode, void *cmd)
{
/* errata "Watch-dog/Software Reset Problem" specifies that
* this reset must be done with the SYSCLK sourced from
* EXTCLK instead of FOUT to avoid a glitch in the reset
* mechanism.
*
* See the watchdog section of the S3C2412 manual for more
* information on this fix.
*/

__raw_writel(0x00, reg_base + CLKSRC);
__raw_writel(0x533C2412, reg_base + SWRST);
return NOTIFY_DONE;
}

static struct notifier_block s3c2412_restart_handler = {
.notifier_call = s3c2412_restart,
.priority = 129,
};

/*
* fixed rate clocks generated outside the soc
* Only necessary until the devicetree-move is complete
Expand Down Expand Up @@ -233,6 +257,7 @@ void __init s3c2412_common_clk_init(struct device_node *np, unsigned long xti_f,
unsigned long ext_f, void __iomem *base)
{
struct samsung_clk_provider *ctx;
int ret;
reg_base = base;

if (np) {
Expand Down Expand Up @@ -267,6 +292,10 @@ void __init s3c2412_common_clk_init(struct device_node *np, unsigned long xti_f,
s3c2412_clk_sleep_init();

samsung_clk_of_add_provider(np, ctx);

ret = register_restart_handler(&s3c2412_restart_handler);
if (ret)
pr_warn("cannot register restart handler, %d\n", ret);
}

static void __init s3c2412_clk_init(struct device_node *np)
Expand Down
19 changes: 19 additions & 0 deletions drivers/clk/samsung/clk-s3c2443.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/syscore_ops.h>
#include <linux/reboot.h>

#include <dt-bindings/clock/s3c2443.h>

Expand All @@ -33,6 +34,7 @@
#define HCLKCON 0x30
#define PCLKCON 0x34
#define SCLKCON 0x38
#define SWRST 0x44

/* the soc types */
enum supported_socs {
Expand Down Expand Up @@ -354,6 +356,18 @@ struct samsung_clock_alias s3c2450_aliases[] __initdata = {
ALIAS(PCLK_I2C1, "s3c2410-i2c.1", "i2c"),
};

static int s3c2443_restart(struct notifier_block *this,
unsigned long mode, void *cmd)
{
__raw_writel(0x533c2443, reg_base + SWRST);
return NOTIFY_DONE;
}

static struct notifier_block s3c2443_restart_handler = {
.notifier_call = s3c2443_restart,
.priority = 129,
};

/*
* fixed rate clocks generated outside the soc
* Only necessary until the devicetree-move is complete
Expand All @@ -378,6 +392,7 @@ void __init s3c2443_common_clk_init(struct device_node *np, unsigned long xti_f,
void __iomem *base)
{
struct samsung_clk_provider *ctx;
int ret;
reg_base = base;

if (np) {
Expand Down Expand Up @@ -447,6 +462,10 @@ void __init s3c2443_common_clk_init(struct device_node *np, unsigned long xti_f,
s3c2443_clk_sleep_init();

samsung_clk_of_add_provider(np, ctx);

ret = register_restart_handler(&s3c2443_restart_handler);
if (ret)
pr_warn("cannot register restart handler, %d\n", ret);
}

static void __init s3c2416_clk_init(struct device_node *np)
Expand Down
3 changes: 2 additions & 1 deletion drivers/power/reset/restart-poweroff.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

static void restart_poweroff_do_poweroff(void)
{
arm_pm_restart(REBOOT_HARD, NULL);
reboot_mode = REBOOT_HARD;
machine_restart(NULL);
}

static int restart_poweroff_probe(struct platform_device *pdev)
Expand Down
42 changes: 32 additions & 10 deletions drivers/watchdog/alim7101_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,28 @@ static struct miscdevice wdt_miscdev = {
.fops = &wdt_fops,
};

static int wdt_restart_handle(struct notifier_block *this, unsigned long mode,
void *cmd)
{
/*
* Cobalt devices have no way of rebooting themselves other
* than getting the watchdog to pull reset, so we restart the
* watchdog on reboot with no heartbeat.
*/
wdt_change(WDT_ENABLE);

/* loop until the watchdog fires */
while (true)
;

return NOTIFY_DONE;
}

static struct notifier_block wdt_restart_handler = {
.notifier_call = wdt_restart_handle,
.priority = 128,
};

/*
* Notifier for system down
*/
Expand All @@ -311,15 +333,6 @@ static int wdt_notify_sys(struct notifier_block *this,
if (code == SYS_DOWN || code == SYS_HALT)
wdt_turnoff();

if (code == SYS_RESTART) {
/*
* Cobalt devices have no way of rebooting themselves other
* than getting the watchdog to pull reset, so we restart the
* watchdog on reboot with no heartbeat
*/
wdt_change(WDT_ENABLE);
pr_info("Watchdog timer is now enabled with no heartbeat - should reboot in ~1 second\n");
}
return NOTIFY_DONE;
}

Expand All @@ -338,6 +351,7 @@ static void __exit alim7101_wdt_unload(void)
/* Deregister */
misc_deregister(&wdt_miscdev);
unregister_reboot_notifier(&wdt_notifier);
unregister_restart_handler(&wdt_restart_handler);
pci_dev_put(alim7101_pmu);
}

Expand Down Expand Up @@ -390,11 +404,17 @@ static int __init alim7101_wdt_init(void)
goto err_out;
}

rc = register_restart_handler(&wdt_restart_handler);
if (rc) {
pr_err("cannot register restart handler (err=%d)\n", rc);
goto err_out_reboot;
}

rc = misc_register(&wdt_miscdev);
if (rc) {
pr_err("cannot register miscdev on minor=%d (err=%d)\n",
wdt_miscdev.minor, rc);
goto err_out_reboot;
goto err_out_restart;
}

if (nowayout)
Expand All @@ -404,6 +424,8 @@ static int __init alim7101_wdt_init(void)
timeout, nowayout);
return 0;

err_out_restart:
unregister_restart_handler(&wdt_restart_handler);
err_out_reboot:
unregister_reboot_notifier(&wdt_notifier);
err_out:
Expand Down
Loading

0 comments on commit a797900

Please sign in to comment.