Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers/misc: (aspeed-lpc-snoop): Add ast2400 to compat

This driver can be used on the aspeed ast2400 with minor
modifications.

Tested: ast2400 on quanta-q71l

Signed-off-by: Patrick Venture <venture@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Patrick Venture and committed by
Greg Kroah-Hartman
2dee584b dd018597

+29 -5
+29 -5
drivers/misc/aspeed-lpc-snoop.c
··· 20 20 #include <linux/mfd/syscon.h> 21 21 #include <linux/module.h> 22 22 #include <linux/of.h> 23 + #include <linux/of_device.h> 23 24 #include <linux/platform_device.h> 24 25 #include <linux/regmap.h> 25 26 ··· 51 50 #define HICRB 0x80 52 51 #define HICRB_ENSNP0D BIT(14) 53 52 #define HICRB_ENSNP1D BIT(15) 53 + 54 + struct aspeed_lpc_snoop_model_data { 55 + /* The ast2400 has bits 14 and 15 as reserved, whereas the ast2500 56 + * can use them. 57 + */ 58 + unsigned int has_hicrb_ensnp; 59 + }; 54 60 55 61 struct aspeed_lpc_snoop { 56 62 struct regmap *regmap; ··· 131 123 } 132 124 133 125 static int aspeed_lpc_enable_snoop(struct aspeed_lpc_snoop *lpc_snoop, 134 - int channel, u16 lpc_port) 126 + struct device *dev, 127 + int channel, u16 lpc_port) 135 128 { 136 129 int rc = 0; 137 130 u32 hicr5_en, snpwadr_mask, snpwadr_shift, hicrb_en; 131 + const struct aspeed_lpc_snoop_model_data *model_data = 132 + of_device_get_match_data(dev); 138 133 139 134 /* Create FIFO datastructure */ 140 135 rc = kfifo_alloc(&lpc_snoop->snoop_fifo[channel], ··· 166 155 regmap_update_bits(lpc_snoop->regmap, HICR5, hicr5_en, hicr5_en); 167 156 regmap_update_bits(lpc_snoop->regmap, SNPWADR, snpwadr_mask, 168 157 lpc_port << snpwadr_shift); 169 - regmap_update_bits(lpc_snoop->regmap, HICRB, hicrb_en, hicrb_en); 158 + if (model_data->has_hicrb_ensnp) 159 + regmap_update_bits(lpc_snoop->regmap, HICRB, 160 + hicrb_en, hicrb_en); 170 161 171 162 return rc; 172 163 } ··· 226 213 if (rc) 227 214 return rc; 228 215 229 - rc = aspeed_lpc_enable_snoop(lpc_snoop, 0, port); 216 + rc = aspeed_lpc_enable_snoop(lpc_snoop, dev, 0, port); 230 217 if (rc) 231 218 return rc; 232 219 233 220 /* Configuration of 2nd snoop channel port is optional */ 234 221 if (of_property_read_u32_index(dev->of_node, "snoop-ports", 235 222 1, &port) == 0) { 236 - rc = aspeed_lpc_enable_snoop(lpc_snoop, 1, port); 223 + rc = aspeed_lpc_enable_snoop(lpc_snoop, dev, 1, port); 237 224 if (rc) 238 225 aspeed_lpc_disable_snoop(lpc_snoop, 0); 239 226 } ··· 252 239 return 0; 253 240 } 254 241 242 + static const struct aspeed_lpc_snoop_model_data ast2400_model_data = { 243 + .has_hicrb_ensnp = 0, 244 + }; 245 + 246 + static const struct aspeed_lpc_snoop_model_data ast2500_model_data = { 247 + .has_hicrb_ensnp = 1, 248 + }; 249 + 255 250 static const struct of_device_id aspeed_lpc_snoop_match[] = { 256 - { .compatible = "aspeed,ast2500-lpc-snoop" }, 251 + { .compatible = "aspeed,ast2400-lpc-snoop", 252 + .data = &ast2400_model_data }, 253 + { .compatible = "aspeed,ast2500-lpc-snoop", 254 + .data = &ast2500_model_data }, 257 255 { }, 258 256 }; 259 257