• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
16 #include <dt-bindings/reset-controller/stih415-resets.h>
17 
18 #include "reset-syscfg.h"
19 
20 /*
21  * STiH415 Peripheral powerdown definitions.
22  */
23 static const char stih415_front[] = "st,stih415-front-syscfg";
24 static const char stih415_rear[] = "st,stih415-rear-syscfg";
25 static const char stih415_sbc[] = "st,stih415-sbc-syscfg";
26 static 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 
34 #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 
46 #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 
52 #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 
57 static 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 
69 static 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),
76 	[STIH415_KEYSCAN_SOFTRESET] = STIH415_SRST_LPM(LPM_SYSCFG_1, 8),
77 };
78 
79 static 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 
85 static 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 
92 static struct of_device_id stih415_reset_match[] = {
93 	{ .compatible = "st,stih415-powerdown",
94 	  .data = &stih415_powerdown_controller, },
95 	{ .compatible = "st,stih415-softreset",
96 	  .data = &stih415_softreset_controller, },
97 	{},
98 };
99 
100 static struct platform_driver stih415_reset_driver = {
101 	.probe = syscfg_reset_probe,
102 	.driver = {
103 		.name = "reset-stih415",
104 		.owner = THIS_MODULE,
105 		.of_match_table = stih415_reset_match,
106 	},
107 };
108 
stih415_reset_init(void)109 static int __init stih415_reset_init(void)
110 {
111 	return platform_driver_register(&stih415_reset_driver);
112 }
113 arch_initcall(stih415_reset_init);
114