pmbus.c (3eb66e91a25497065c5322b1268cbc3953642227) | pmbus.c (6f4a46f0eb5e7a58be38284c7124ad8b96298b35) |
---|---|
1/* 2 * Hardware monitoring driver for PMBus devices 3 * 4 * Copyright (c) 2010, 2011 Ericsson AB. 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 --- 14 unchanged lines hidden (view full) --- 23#include <linux/init.h> 24#include <linux/err.h> 25#include <linux/slab.h> 26#include <linux/mutex.h> 27#include <linux/i2c.h> 28#include <linux/pmbus.h> 29#include "pmbus.h" 30 | 1/* 2 * Hardware monitoring driver for PMBus devices 3 * 4 * Copyright (c) 2010, 2011 Ericsson AB. 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 --- 14 unchanged lines hidden (view full) --- 23#include <linux/init.h> 24#include <linux/err.h> 25#include <linux/slab.h> 26#include <linux/mutex.h> 27#include <linux/i2c.h> 28#include <linux/pmbus.h> 29#include "pmbus.h" 30 |
31struct pmbus_device_info { 32 int pages; 33 u32 flags; 34}; 35 |
|
31/* 32 * Find sensor groups and status registers on each page. 33 */ 34static void pmbus_find_sensor_groups(struct i2c_client *client, 35 struct pmbus_driver_info *info) 36{ 37 int page; 38 --- 128 unchanged lines hidden (view full) --- 167} 168 169static int pmbus_probe(struct i2c_client *client, 170 const struct i2c_device_id *id) 171{ 172 struct pmbus_driver_info *info; 173 struct pmbus_platform_data *pdata = NULL; 174 struct device *dev = &client->dev; | 36/* 37 * Find sensor groups and status registers on each page. 38 */ 39static void pmbus_find_sensor_groups(struct i2c_client *client, 40 struct pmbus_driver_info *info) 41{ 42 int page; 43 --- 128 unchanged lines hidden (view full) --- 172} 173 174static int pmbus_probe(struct i2c_client *client, 175 const struct i2c_device_id *id) 176{ 177 struct pmbus_driver_info *info; 178 struct pmbus_platform_data *pdata = NULL; 179 struct device *dev = &client->dev; |
180 struct pmbus_device_info *device_info; |
|
175 176 info = devm_kzalloc(dev, sizeof(struct pmbus_driver_info), GFP_KERNEL); 177 if (!info) 178 return -ENOMEM; 179 | 181 182 info = devm_kzalloc(dev, sizeof(struct pmbus_driver_info), GFP_KERNEL); 183 if (!info) 184 return -ENOMEM; 185 |
180 if (!strcmp(id->name, "dps460") || !strcmp(id->name, "dps800") || 181 !strcmp(id->name, "sgd009")) { | 186 device_info = (struct pmbus_device_info *)id->driver_data; 187 if (device_info->flags & PMBUS_SKIP_STATUS_CHECK) { |
182 pdata = devm_kzalloc(dev, sizeof(struct pmbus_platform_data), 183 GFP_KERNEL); 184 if (!pdata) 185 return -ENOMEM; 186 187 pdata->flags = PMBUS_SKIP_STATUS_CHECK; 188 } 189 | 188 pdata = devm_kzalloc(dev, sizeof(struct pmbus_platform_data), 189 GFP_KERNEL); 190 if (!pdata) 191 return -ENOMEM; 192 193 pdata->flags = PMBUS_SKIP_STATUS_CHECK; 194 } 195 |
190 info->pages = id->driver_data; | 196 info->pages = device_info->pages; |
191 info->identify = pmbus_identify; 192 dev->platform_data = pdata; 193 194 return pmbus_do_probe(client, id, info); 195} 196 | 197 info->identify = pmbus_identify; 198 dev->platform_data = pdata; 199 200 return pmbus_do_probe(client, id, info); 201} 202 |
203static const struct pmbus_device_info pmbus_info_one = { 204 .pages = 1, 205 .flags = 0 206}; 207static const struct pmbus_device_info pmbus_info_zero = { 208 .pages = 0, 209 .flags = 0 210}; 211static const struct pmbus_device_info pmbus_info_one_skip = { 212 .pages = 1, 213 .flags = PMBUS_SKIP_STATUS_CHECK 214}; 215 |
|
197/* 198 * Use driver_data to set the number of pages supported by the chip. 199 */ 200static const struct i2c_device_id pmbus_id[] = { | 216/* 217 * Use driver_data to set the number of pages supported by the chip. 218 */ 219static const struct i2c_device_id pmbus_id[] = { |
201 {"adp4000", 1}, 202 {"bmr453", 1}, 203 {"bmr454", 1}, 204 {"dps460", 1}, 205 {"dps800", 1}, 206 {"mdt040", 1}, 207 {"ncp4200", 1}, 208 {"ncp4208", 1}, 209 {"pdt003", 1}, 210 {"pdt006", 1}, 211 {"pdt012", 1}, 212 {"pmbus", 0}, 213 {"sgd009", 1}, 214 {"tps40400", 1}, 215 {"tps544b20", 1}, 216 {"tps544b25", 1}, 217 {"tps544c20", 1}, 218 {"tps544c25", 1}, 219 {"udt020", 1}, | 220 {"adp4000", (kernel_ulong_t)&pmbus_info_one}, 221 {"bmr453", (kernel_ulong_t)&pmbus_info_one}, 222 {"bmr454", (kernel_ulong_t)&pmbus_info_one}, 223 {"dps460", (kernel_ulong_t)&pmbus_info_one_skip}, 224 {"dps800", (kernel_ulong_t)&pmbus_info_one_skip}, 225 {"mdt040", (kernel_ulong_t)&pmbus_info_one}, 226 {"ncp4200", (kernel_ulong_t)&pmbus_info_one}, 227 {"ncp4208", (kernel_ulong_t)&pmbus_info_one}, 228 {"pdt003", (kernel_ulong_t)&pmbus_info_one}, 229 {"pdt006", (kernel_ulong_t)&pmbus_info_one}, 230 {"pdt012", (kernel_ulong_t)&pmbus_info_one}, 231 {"pmbus", (kernel_ulong_t)&pmbus_info_zero}, 232 {"sgd009", (kernel_ulong_t)&pmbus_info_one_skip}, 233 {"tps40400", (kernel_ulong_t)&pmbus_info_one}, 234 {"tps544b20", (kernel_ulong_t)&pmbus_info_one}, 235 {"tps544b25", (kernel_ulong_t)&pmbus_info_one}, 236 {"tps544c20", (kernel_ulong_t)&pmbus_info_one}, 237 {"tps544c25", (kernel_ulong_t)&pmbus_info_one}, 238 {"udt020", (kernel_ulong_t)&pmbus_info_one}, |
220 {} 221}; 222 223MODULE_DEVICE_TABLE(i2c, pmbus_id); 224 225/* This is the driver that will be inserted */ 226static struct i2c_driver pmbus_driver = { 227 .driver = { --- 12 unchanged lines hidden --- | 239 {} 240}; 241 242MODULE_DEVICE_TABLE(i2c, pmbus_id); 243 244/* This is the driver that will be inserted */ 245static struct i2c_driver pmbus_driver = { 246 .driver = { --- 12 unchanged lines hidden --- |