2008-06-27 17:37:19 +08:00
|
|
|
/*
|
|
|
|
* drivers/mfd/mfd-core.h
|
|
|
|
*
|
|
|
|
* core MFD support
|
|
|
|
* Copyright (c) 2006 Ian Molton
|
|
|
|
* Copyright (c) 2007 Dmitry Baryshkov
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-07-29 00:29:09 +08:00
|
|
|
#ifndef MFD_CORE_H
|
|
|
|
#define MFD_CORE_H
|
|
|
|
|
2008-06-27 17:37:19 +08:00
|
|
|
#include <linux/platform_device.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This struct describes the MFD part ("cell").
|
|
|
|
* After registration the copy of this structure will become the platform data
|
|
|
|
* of the resulting platform_device
|
|
|
|
*/
|
|
|
|
struct mfd_cell {
|
|
|
|
const char *name;
|
2009-07-27 21:45:51 +08:00
|
|
|
int id;
|
2008-06-27 17:37:19 +08:00
|
|
|
|
2011-02-18 11:07:34 +08:00
|
|
|
/* refcounting for multiple drivers to use a single cell */
|
|
|
|
atomic_t *usage_count;
|
2008-06-27 17:37:19 +08:00
|
|
|
int (*enable)(struct platform_device *dev);
|
|
|
|
int (*disable)(struct platform_device *dev);
|
2011-02-18 11:07:34 +08:00
|
|
|
|
2008-06-27 17:37:19 +08:00
|
|
|
int (*suspend)(struct platform_device *dev);
|
|
|
|
int (*resume)(struct platform_device *dev);
|
|
|
|
|
2011-02-18 11:07:25 +08:00
|
|
|
/* mfd_data can be used to pass data to client drivers */
|
|
|
|
void *mfd_data;
|
2011-02-18 11:07:09 +08:00
|
|
|
|
2008-06-27 17:37:19 +08:00
|
|
|
/*
|
2011-02-18 11:07:08 +08:00
|
|
|
* These resources can be specified relative to the parent device.
|
|
|
|
* For accessing hardware you should use resources from the platform dev
|
2008-06-27 17:37:19 +08:00
|
|
|
*/
|
|
|
|
int num_resources;
|
|
|
|
const struct resource *resources;
|
2010-10-01 04:55:36 +08:00
|
|
|
|
|
|
|
/* don't check for resource conflicts */
|
|
|
|
bool ignore_resource_conflicts;
|
2010-11-27 01:19:34 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable runtime PM callbacks for this subdevice - see
|
|
|
|
* pm_runtime_no_callbacks().
|
|
|
|
*/
|
|
|
|
bool pm_runtime_no_callbacks;
|
2008-06-27 17:37:19 +08:00
|
|
|
};
|
|
|
|
|
2011-02-18 11:07:34 +08:00
|
|
|
/*
|
|
|
|
* Convenience functions for clients using shared cells. Refcounting
|
|
|
|
* happens automatically, with the cell's enable/disable callbacks
|
|
|
|
* being called only when a device is first being enabled or no other
|
|
|
|
* clients are making use of it.
|
|
|
|
*/
|
|
|
|
extern int mfd_shared_cell_enable(struct platform_device *pdev);
|
|
|
|
extern int mfd_shared_cell_disable(struct platform_device *pdev);
|
|
|
|
|
2011-02-18 11:07:09 +08:00
|
|
|
/*
|
|
|
|
* Given a platform device that's been created by mfd_add_devices(), fetch
|
|
|
|
* the mfd_cell that created it.
|
|
|
|
*/
|
|
|
|
static inline const struct mfd_cell *mfd_get_cell(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
return pdev->dev.platform_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Given a platform device that's been created by mfd_add_devices(), fetch
|
2011-02-18 11:07:25 +08:00
|
|
|
* the .mfd_data entry from the mfd_cell that created it.
|
2011-02-18 11:07:09 +08:00
|
|
|
*/
|
|
|
|
static inline void *mfd_get_data(struct platform_device *pdev)
|
|
|
|
{
|
2011-02-18 11:07:25 +08:00
|
|
|
return mfd_get_cell(pdev)->mfd_data;
|
2011-02-18 11:07:09 +08:00
|
|
|
}
|
|
|
|
|
2008-07-29 07:30:26 +08:00
|
|
|
extern int mfd_add_devices(struct device *parent, int id,
|
2011-02-18 11:07:34 +08:00
|
|
|
struct mfd_cell *cells, int n_devs,
|
2008-07-29 00:29:09 +08:00
|
|
|
struct resource *mem_base,
|
|
|
|
int irq_base);
|
2008-06-27 17:37:19 +08:00
|
|
|
|
2008-07-29 07:30:26 +08:00
|
|
|
extern void mfd_remove_devices(struct device *parent);
|
2008-06-27 17:37:19 +08:00
|
|
|
|
2011-02-18 11:07:35 +08:00
|
|
|
/*
|
|
|
|
* For MFD drivers with clients sharing access to resources, these create
|
|
|
|
* multiple platform devices per cell. Contention handling must still be
|
|
|
|
* handled via drivers (ie, with enable/disable hooks).
|
|
|
|
*/
|
|
|
|
extern int mfd_shared_platform_driver_register(struct platform_driver *drv,
|
|
|
|
const char *cellname);
|
|
|
|
extern void mfd_shared_platform_driver_unregister(struct platform_driver *drv);
|
|
|
|
|
2008-06-27 17:37:19 +08:00
|
|
|
#endif
|