brintos

brintos / linux-shallow public Read only

0
0
Text · 2.1 KiB · 797bf67 Raw
80 lines · c
1// SPDX-License-Identifier: GPL-2.0-only2/*3 * Reset driver for Axxia devices4 *5 * Copyright (C) 2014 LSI6 */7#include <linux/init.h>8#include <linux/err.h>9#include <linux/io.h>10#include <linux/kernel.h>11#include <linux/mfd/syscon.h>12#include <linux/module.h>13#include <linux/notifier.h>14#include <linux/of.h>15#include <linux/platform_device.h>16#include <linux/reboot.h>17#include <linux/regmap.h>18 19#define SC_CRIT_WRITE_KEY	0x100020#define SC_LATCH_ON_RESET	0x100421#define SC_RESET_CONTROL	0x100822#define   RSTCTL_RST_ZERO	(1<<3)23#define   RSTCTL_RST_FAB	(1<<2)24#define   RSTCTL_RST_CHIP	(1<<1)25#define   RSTCTL_RST_SYS	(1<<0)26#define SC_EFUSE_INT_STATUS	0x180c27#define   EFUSE_READ_DONE	(1<<31)28 29static int axxia_restart_handler(struct sys_off_data *data)30{31	struct regmap *syscon = data->cb_data;32 33	/* Access Key (0xab) */34	regmap_write(syscon, SC_CRIT_WRITE_KEY, 0xab);35	/* Select internal boot from 0xffff0000 */36	regmap_write(syscon, SC_LATCH_ON_RESET, 0x00000040);37	/* Assert ResetReadDone (to avoid hanging in boot ROM) */38	regmap_write(syscon, SC_EFUSE_INT_STATUS, EFUSE_READ_DONE);39	/* Assert chip reset */40	regmap_update_bits(syscon, SC_RESET_CONTROL,41			   RSTCTL_RST_CHIP, RSTCTL_RST_CHIP);42 43	return NOTIFY_DONE;44}45 46static int axxia_reset_probe(struct platform_device *pdev)47{48	struct device *dev = &pdev->dev;49	struct regmap *syscon;50	int err;51 52	syscon = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon");53	if (IS_ERR(syscon)) {54		pr_err("%pOFn: syscon lookup failed\n", dev->of_node);55		return PTR_ERR(syscon);56	}57 58	err = devm_register_sys_off_handler(&pdev->dev, SYS_OFF_MODE_RESTART,59					    128, axxia_restart_handler, syscon);60	if (err)61		dev_err(dev, "cannot register restart handler (err=%d)\n", err);62 63	return err;64}65 66static const struct of_device_id of_axxia_reset_match[] = {67	{ .compatible = "lsi,axm55xx-reset", },68	{},69};70MODULE_DEVICE_TABLE(of, of_axxia_reset_match);71 72static struct platform_driver axxia_reset_driver = {73	.probe = axxia_reset_probe,74	.driver = {75		.name = "axxia-reset",76		.of_match_table = of_match_ptr(of_axxia_reset_match),77	},78};79builtin_platform_driver(axxia_reset_driver);80