2020#include <linux/mfd/syscon.h>
2121#include <linux/module.h>
2222#include <linux/of.h>
23+ #include <linux/of_device.h>
2324#include <linux/platform_device.h>
2425#include <linux/regmap.h>
2526
5152#define HICRB_ENSNP0D BIT(14)
5253#define HICRB_ENSNP1D BIT(15)
5354
55+ struct aspeed_lpc_snoop_model_data {
56+ /* The ast2400 has bits 14 and 15 as reserved, whereas the ast2500
57+ * can use them.
58+ */
59+ unsigned int has_hicrb_ensnp ;
60+ };
61+
5462struct aspeed_lpc_snoop {
5563 struct regmap * regmap ;
5664 int irq ;
@@ -123,10 +131,13 @@ static int aspeed_lpc_snoop_config_irq(struct aspeed_lpc_snoop *lpc_snoop,
123131}
124132
125133static int aspeed_lpc_enable_snoop (struct aspeed_lpc_snoop * lpc_snoop ,
126- int channel , u16 lpc_port )
134+ struct device * dev ,
135+ int channel , u16 lpc_port )
127136{
128137 int rc = 0 ;
129138 u32 hicr5_en , snpwadr_mask , snpwadr_shift , hicrb_en ;
139+ const struct aspeed_lpc_snoop_model_data * model_data =
140+ of_device_get_match_data (dev );
130141
131142 /* Create FIFO datastructure */
132143 rc = kfifo_alloc (& lpc_snoop -> snoop_fifo [channel ],
@@ -155,7 +166,9 @@ static int aspeed_lpc_enable_snoop(struct aspeed_lpc_snoop *lpc_snoop,
155166 regmap_update_bits (lpc_snoop -> regmap , HICR5 , hicr5_en , hicr5_en );
156167 regmap_update_bits (lpc_snoop -> regmap , SNPWADR , snpwadr_mask ,
157168 lpc_port << snpwadr_shift );
158- regmap_update_bits (lpc_snoop -> regmap , HICRB , hicrb_en , hicrb_en );
169+ if (model_data -> has_hicrb_ensnp )
170+ regmap_update_bits (lpc_snoop -> regmap , HICRB ,
171+ hicrb_en , hicrb_en );
159172
160173 return rc ;
161174}
@@ -213,14 +226,14 @@ static int aspeed_lpc_snoop_probe(struct platform_device *pdev)
213226 if (rc )
214227 return rc ;
215228
216- rc = aspeed_lpc_enable_snoop (lpc_snoop , 0 , port );
229+ rc = aspeed_lpc_enable_snoop (lpc_snoop , dev , 0 , port );
217230 if (rc )
218231 return rc ;
219232
220233 /* Configuration of 2nd snoop channel port is optional */
221234 if (of_property_read_u32_index (dev -> of_node , "snoop-ports" ,
222235 1 , & port ) == 0 ) {
223- rc = aspeed_lpc_enable_snoop (lpc_snoop , 1 , port );
236+ rc = aspeed_lpc_enable_snoop (lpc_snoop , dev , 1 , port );
224237 if (rc )
225238 aspeed_lpc_disable_snoop (lpc_snoop , 0 );
226239 }
@@ -239,8 +252,19 @@ static int aspeed_lpc_snoop_remove(struct platform_device *pdev)
239252 return 0 ;
240253}
241254
255+ static const struct aspeed_lpc_snoop_model_data ast2400_model_data = {
256+ .has_hicrb_ensnp = 0 ,
257+ };
258+
259+ static const struct aspeed_lpc_snoop_model_data ast2500_model_data = {
260+ .has_hicrb_ensnp = 1 ,
261+ };
262+
242263static const struct of_device_id aspeed_lpc_snoop_match [] = {
243- { .compatible = "aspeed,ast2500-lpc-snoop" },
264+ { .compatible = "aspeed,ast2400-lpc-snoop" ,
265+ .data = & ast2400_model_data },
266+ { .compatible = "aspeed,ast2500-lpc-snoop" ,
267+ .data = & ast2500_model_data },
244268 { },
245269};
246270
0 commit comments