drivers: hwmon OCC scom bus operations
PATCH v5 3/5 drivers: hwmon OCC scom bus operations
From: "Edward A. James" <[email protected]>
Add i2c bus operations to perform scom functions
Signed-off-by Edward A. James <[email protected]>
--- drivers/hwmon/occ/occ.c | 23 ++++++++++++++- drivers/hwmon/occ/occ.h | 4 ++- drivers/hwmon/occ/occ_i2c.c | 72 ++++++++++++++++++++++++++++++++++++++++++++- drivers/hwmon/occ/p8.c | 4 +-- drivers/hwmon/occ/p8.h | 4 ++- drivers/hwmon/occ/p9.c | 4 +-- drivers/hwmon/occ/p9.h | 4 ++- drivers/hwmon/occ/scom.h | 31 +++++++++++++++++++ 8 files changed, 137 insertions(+), 9 deletions(-) create mode 100644 drivers/hwmon/occ/scom.h
drivers/hwmon/occ/occ.c +22 -1
@@ -30,13 +30,34 @@#include "occ.h" -int occ_start (struct device *dev) +struct occ_driver { +void *bus; +struct occ_bus_ops bus_ops; +}; + +int occ_start (struct device *dev,void *bus,struct occ_bus_ops bus_ops) { +struct occ_driver *driver =devm_kzalloc (dev, +sizeof (struct occ_driver ), +GFP_KERNEL ); +if (!driver) +return -ENOMEM ; + +dev_set_drvdata (dev, driver); + + driver->bus = bus; + driver->bus_ops = bus_ops; +return 0 ; }int occ_stop (struct device *dev) { +struct occ_driver *driver =dev_get_drvdata (dev); + +if (driver) +devm_kfree (dev, driver); +return 0 ; }
drivers/hwmon/occ/occ.h +3 -1
@@ -20,9 +20,11 @@#ifndef __OCC_H__#define __OCC_H__ +#include "scom.h" +struct device ; -int occ_start (struct device *dev); +int occ_start (struct device *dev,void *bus,struct occ_bus_ops bus_ops);int occ_stop (struct device *dev);#endif /* __OCC_H__ */
drivers/hwmon/occ/occ_i2c.c +71 -1
85 lines not on this page · raw message
drivers/hwmon/occ/p8.c +2 -2
@@ -28,9 +28,9 @@#include "occ.h" -int p8_occ_start (struct device *dev) +int p8_occ_start (struct device *dev,void *bus,struct occ_bus_ops bus_ops) { -return occ_start (dev); +return occ_start (dev, bus, bus_ops); }int p8_occ_stop (struct device *dev)
drivers/hwmon/occ/p8.h +3 -1
@@ -19,9 +19,11 @@#ifndef __P8_H__#define __P8_H__ +#include "scom.h" +struct device ; -int p8_occ_start (struct device *dev); +int p8_occ_start (struct device *dev,void *bus,struct occ_bus_ops bus_ops);int p8_occ_stop (struct device *dev);#endif /* __P8_H__ */
drivers/hwmon/occ/p9.c +2 -2
@@ -28,9 +28,9 @@#include "occ.h" -int p9_occ_start (struct device *dev) +int p9_occ_start (struct device *dev,void *bus,struct occ_bus_ops bus_ops) { -return occ_start (dev); +return occ_start (dev, bus, bus_ops); }int p9_occ_stop (struct device *dev)
drivers/hwmon/occ/p9.h +3 -1
@@ -19,9 +19,11 @@#ifndef __P9_H__#define __P9_H__ +#include "scom.h" +struct device ; -int p9_occ_start (struct device *dev); +int p9_occ_start (struct device *dev,void *bus,struct occ_bus_ops bus_ops);int p9_occ_stop (struct device *dev);#endif /* __P9_H__ */
drivers/hwmon/occ/scom.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* scom.h - hwmon OCC driver +* +* This file contains data structures for scom operations to the OCC +* +* Copyright 2016 IBM Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __SCOM_H__ +#define __SCOM_H__ + +/* +* occ_bus_ops - represent the low-level transfer methods to communicate with +* the OCC. +*/ +struct occ_bus_ops { +int (*getscom)(void *bus,u32 address,u8 *data,size_t offset); +int (*putscom)(void *bus,u32 address,u32 data0,u32 data1); +}; + +#endif /* __SCOM_H__ */
Signature · 1 line
1.9.1