blob: 6f220cdbef46ce5246164a9c434a4c976dfc5823 [file] [log] [blame]
Stephen Gallimore1f42c292013-08-07 16:31:25 +01001/*
2 * Copyright (C) 2013 STMicroelectronics (R&D) Limited
3 * Author: Stephen Gallimore <stephen.gallimore@st.com>
4 * Author: Srinivas Kandagatla <srinivas.kandagatla@st.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11#include <linux/module.h>
12#include <linux/of.h>
13#include <linux/of_platform.h>
14#include <linux/platform_device.h>
15
Philipp Zabelefdf5aa2015-02-13 12:20:49 +010016#include <dt-bindings/reset/stih415-resets.h>
Stephen Gallimore1f42c292013-08-07 16:31:25 +010017
18#include "reset-syscfg.h"
19
20/*
21 * STiH415 Peripheral powerdown definitions.
22 */
23static const char stih415_front[] = "st,stih415-front-syscfg";
24static const char stih415_rear[] = "st,stih415-rear-syscfg";
25static const char stih415_sbc[] = "st,stih415-sbc-syscfg";
26static const char stih415_lpm[] = "st,stih415-lpm-syscfg";
27
28#define STIH415_PDN_FRONT(_bit) \
29 _SYSCFG_RST_CH(stih415_front, SYSCFG_114, _bit, SYSSTAT_187, _bit)
30
31#define STIH415_PDN_REAR(_cntl, _stat) \
32 _SYSCFG_RST_CH(stih415_rear, SYSCFG_336, _cntl, SYSSTAT_384, _stat)
33
Srinivas Kandagatlaa596ebd2013-11-12 10:22:56 +000034#define STIH415_SRST_REAR(_reg, _bit) \
35 _SYSCFG_RST_CH_NO_ACK(stih415_rear, _reg, _bit)
36
37#define STIH415_SRST_SBC(_reg, _bit) \
38 _SYSCFG_RST_CH_NO_ACK(stih415_sbc, _reg, _bit)
39
40#define STIH415_SRST_FRONT(_reg, _bit) \
41 _SYSCFG_RST_CH_NO_ACK(stih415_front, _reg, _bit)
42
43#define STIH415_SRST_LPM(_reg, _bit) \
44 _SYSCFG_RST_CH_NO_ACK(stih415_lpm, _reg, _bit)
45
Stephen Gallimore1f42c292013-08-07 16:31:25 +010046#define SYSCFG_114 0x38 /* Powerdown request EMI/NAND/Keyscan */
47#define SYSSTAT_187 0x15c /* Powerdown status EMI/NAND/Keyscan */
48
49#define SYSCFG_336 0x90 /* Powerdown request USB/SATA/PCIe */
50#define SYSSTAT_384 0x150 /* Powerdown status USB/SATA/PCIe */
51
Srinivas Kandagatlaa596ebd2013-11-12 10:22:56 +000052#define SYSCFG_376 0x130 /* Reset generator 0 control 0 */
53#define SYSCFG_166 0x108 /* Softreset Ethernet 0 */
54#define SYSCFG_31 0x7c /* Softreset Ethernet 1 */
55#define LPM_SYSCFG_1 0x4 /* Softreset IRB */
56
Stephen Gallimore1f42c292013-08-07 16:31:25 +010057static const struct syscfg_reset_channel_data stih415_powerdowns[] = {
58 [STIH415_EMISS_POWERDOWN] = STIH415_PDN_FRONT(0),
59 [STIH415_NAND_POWERDOWN] = STIH415_PDN_FRONT(1),
60 [STIH415_KEYSCAN_POWERDOWN] = STIH415_PDN_FRONT(2),
61 [STIH415_USB0_POWERDOWN] = STIH415_PDN_REAR(0, 0),
62 [STIH415_USB1_POWERDOWN] = STIH415_PDN_REAR(1, 1),
63 [STIH415_USB2_POWERDOWN] = STIH415_PDN_REAR(2, 2),
64 [STIH415_SATA0_POWERDOWN] = STIH415_PDN_REAR(3, 3),
65 [STIH415_SATA1_POWERDOWN] = STIH415_PDN_REAR(4, 4),
66 [STIH415_PCIE_POWERDOWN] = STIH415_PDN_REAR(5, 8),
67};
68
Srinivas Kandagatlaa596ebd2013-11-12 10:22:56 +000069static const struct syscfg_reset_channel_data stih415_softresets[] = {
70 [STIH415_ETH0_SOFTRESET] = STIH415_SRST_FRONT(SYSCFG_166, 0),
71 [STIH415_ETH1_SOFTRESET] = STIH415_SRST_SBC(SYSCFG_31, 0),
72 [STIH415_IRB_SOFTRESET] = STIH415_SRST_LPM(LPM_SYSCFG_1, 6),
73 [STIH415_USB0_SOFTRESET] = STIH415_SRST_REAR(SYSCFG_376, 9),
74 [STIH415_USB1_SOFTRESET] = STIH415_SRST_REAR(SYSCFG_376, 10),
75 [STIH415_USB2_SOFTRESET] = STIH415_SRST_REAR(SYSCFG_376, 11),
Gabriel FERNANDEZce73d9b2014-04-11 17:07:00 +020076 [STIH415_KEYSCAN_SOFTRESET] = STIH415_SRST_LPM(LPM_SYSCFG_1, 8),
Srinivas Kandagatlaa596ebd2013-11-12 10:22:56 +000077};
78
Stephen Gallimore1f42c292013-08-07 16:31:25 +010079static struct syscfg_reset_controller_data stih415_powerdown_controller = {
80 .wait_for_ack = true,
81 .nr_channels = ARRAY_SIZE(stih415_powerdowns),
82 .channels = stih415_powerdowns,
83};
84
Srinivas Kandagatlaa596ebd2013-11-12 10:22:56 +000085static struct syscfg_reset_controller_data stih415_softreset_controller = {
86 .wait_for_ack = false,
87 .active_low = true,
88 .nr_channels = ARRAY_SIZE(stih415_softresets),
89 .channels = stih415_softresets,
90};
91
Fabian Fredericka518db42015-03-16 20:54:37 +010092static const struct of_device_id stih415_reset_match[] = {
Stephen Gallimore1f42c292013-08-07 16:31:25 +010093 { .compatible = "st,stih415-powerdown",
94 .data = &stih415_powerdown_controller, },
Srinivas Kandagatlaa596ebd2013-11-12 10:22:56 +000095 { .compatible = "st,stih415-softreset",
96 .data = &stih415_softreset_controller, },
Stephen Gallimore1f42c292013-08-07 16:31:25 +010097 {},
98};
99
100static struct platform_driver stih415_reset_driver = {
101 .probe = syscfg_reset_probe,
102 .driver = {
103 .name = "reset-stih415",
Stephen Gallimore1f42c292013-08-07 16:31:25 +0100104 .of_match_table = stih415_reset_match,
105 },
106};
107
108static int __init stih415_reset_init(void)
109{
110 return platform_driver_register(&stih415_reset_driver);
111}
112arch_initcall(stih415_reset_init);