Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
platform.c File Reference
#include <linux/string.h>
#include <linux/platform_device.h>
#include <linux/of_device.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/dma-mapping.h>
#include <linux/bootmem.h>
#include <linux/err.h>
#include <linux/slab.h>
#include <linux/pm_runtime.h>
#include <linux/idr.h>
#include "base.h"
#include "power/power.h"

Go to the source code of this file.

Data Structures

struct  platform_object
 

Macros

#define to_platform_driver(drv)
 

Functions

 EXPORT_SYMBOL_GPL (platform_bus)
 
void __weak arch_setup_pdev_archdata (struct platform_device *pdev)
 
struct resourceplatform_get_resource (struct platform_device *dev, unsigned int type, unsigned int num)
 
 EXPORT_SYMBOL_GPL (platform_get_resource)
 
int platform_get_irq (struct platform_device *dev, unsigned int num)
 
 EXPORT_SYMBOL_GPL (platform_get_irq)
 
: resource name

platform_get_resource_byname - get a resource for a device by name : platform device : resource type

struct resourceplatform_get_resource_byname (struct platform_device *dev, unsigned int type, const char *name)
 
 EXPORT_SYMBOL_GPL (platform_get_resource_byname)
 
: IRQ name

platform_get_irq - get an IRQ for a device : platform device

int platform_get_irq_byname (struct platform_device *dev, const char *name)
 
 EXPORT_SYMBOL_GPL (platform_get_irq_byname)
 
int platform_add_devices (struct platform_device **devs, int num)
 
 EXPORT_SYMBOL_GPL (platform_add_devices)
 
void platform_device_put (struct platform_device *pdev)
 
 EXPORT_SYMBOL_GPL (platform_device_put)
 

Variables

struct device platform_bus
 

: base name of the device we're adding

platform_device_alloc - create a platform device

: instance id

Create a platform device object which can have other objects attached to it, and which will have attached objects freed when it is released.

struct bus_type platform_bus_type
 
struct platform_deviceplatform_device_alloc (const char *name, int id)
 
 EXPORT_SYMBOL_GPL (platform_device_alloc)
 
int platform_device_add_resources (struct platform_device *pdev, const struct resource *res, unsigned int num)
 
 EXPORT_SYMBOL_GPL (platform_device_add_resources)
 
int platform_device_add_data (struct platform_device *pdev, const void *data, size_t size)
 
 EXPORT_SYMBOL_GPL (platform_device_add_data)
 
int platform_device_add (struct platform_device *pdev)
 
 EXPORT_SYMBOL_GPL (platform_device_add)
 
void platform_device_del (struct platform_device *pdev)
 
 EXPORT_SYMBOL_GPL (platform_device_del)
 
int platform_device_register (struct platform_device *pdev)
 
 EXPORT_SYMBOL_GPL (platform_device_register)
 
void platform_device_unregister (struct platform_device *pdev)
 
 EXPORT_SYMBOL_GPL (platform_device_unregister)
 
struct platform_deviceplatform_device_register_full (const struct platform_device_info *pdevinfo)
 
 EXPORT_SYMBOL_GPL (platform_device_register_full)
 
int platform_driver_register (struct platform_driver *drv)
 
 EXPORT_SYMBOL_GPL (platform_driver_register)
 
void platform_driver_unregister (struct platform_driver *drv)
 
 EXPORT_SYMBOL_GPL (platform_driver_unregister)
 
int __init_or_module platform_driver_probe (struct platform_driver *drv, int(*probe)(struct platform_device *))
 
 EXPORT_SYMBOL_GPL (platform_driver_probe)
 
struct platform_device
*__init_or_module 
platform_create_bundle (struct platform_driver *driver, int(*probe)(struct platform_device *), struct resource *res, unsigned int n_res, const void *data, size_t size)
 
 EXPORT_SYMBOL_GPL (platform_create_bundle)
 
 EXPORT_SYMBOL_GPL (platform_bus_type)
 
int __init platform_bus_init (void)
 
u64 dma_get_required_mask (struct device *dev)
 
 EXPORT_SYMBOL_GPL (dma_get_required_mask)
 
int __init early_platform_driver_register (struct early_platform_driver *epdrv, char *buf)
 
void __init early_platform_add_devices (struct platform_device **devs, int num)
 
void __init early_platform_driver_register_all (char *class_str)
 
int __init early_platform_driver_probe (char *class_str, int nr_probe, int user_only)
 
void __init early_platform_cleanup (void)
 

Macro Definition Documentation

#define to_platform_driver (   drv)
Value:
(container_of((drv), struct platform_driver, \

Definition at line 31 of file platform.c.

Function Documentation

void __weak arch_setup_pdev_archdata ( struct platform_device pdev)

arch_setup_pdev_archdata - Allow manipulation of archdata before its used : platform device

This is called before platform_device_add() such that any pdev_archdata may be setup before the platform_notifier is called. So if a user needs to manipulate any relevant information in the pdev_archdata they can do:

platform_devic_alloc()
... manipulate ...
platform_device_add()

And if they don't care they can just call platform_device_register() and everything will just work out.

Definition at line 54 of file platform.c.

u64 dma_get_required_mask ( struct device dev)

Definition at line 896 of file platform.c.

void __init early_platform_add_devices ( struct platform_device **  devs,
int  num 
)

early_platform_add_devices - adds a number of early platform devices : array of early platform devices to add : number of early platform devices in array

Used by early architecture code to register early platform devices and their platform data.

Definition at line 984 of file platform.c.

void __init early_platform_cleanup ( void  )

early_platform_cleanup - clean up early platform code

Definition at line 1190 of file platform.c.

int __init early_platform_driver_probe ( char class_str,
int  nr_probe,
int  user_only 
)

early_platform_driver_probe - probe a class of registered drivers : string to identify early platform driver class : number of platform devices to successfully probe before exiting : only probe user specified early platform devices

Used by architecture code to probe registered early platform drivers within a certain class. For probe to happen a registered early platform device matching a registered early platform driver is needed.

Definition at line 1165 of file platform.c.

int __init early_platform_driver_register ( struct early_platform_driver epdrv,
char buf 
)

early_platform_driver_register - register early platform driver : early_platform driver structure : string passed from early_param()

Helper function for early_platform_init() / early_platform_init_buffer()

Definition at line 927 of file platform.c.

void __init early_platform_driver_register_all ( char class_str)

early_platform_driver_register_all - register early platform drivers : string to identify early platform driver class

Used by architecture code to register all early platform drivers for a certain class. If omitted then only early platform drivers with matching kernel command line class parameters will be registered.

Definition at line 1010 of file platform.c.

EXPORT_SYMBOL_GPL ( platform_bus  )
EXPORT_SYMBOL_GPL ( platform_get_resource  )
EXPORT_SYMBOL_GPL ( platform_get_irq  )
EXPORT_SYMBOL_GPL ( platform_get_resource_byname  )
EXPORT_SYMBOL_GPL ( platform_get_irq_byname  )
EXPORT_SYMBOL_GPL ( platform_add_devices  )
EXPORT_SYMBOL_GPL ( platform_device_put  )
EXPORT_SYMBOL_GPL ( platform_device_alloc  )
EXPORT_SYMBOL_GPL ( platform_device_add_resources  )
EXPORT_SYMBOL_GPL ( platform_device_add_data  )
EXPORT_SYMBOL_GPL ( platform_device_add  )
EXPORT_SYMBOL_GPL ( platform_device_del  )
EXPORT_SYMBOL_GPL ( platform_device_register  )
EXPORT_SYMBOL_GPL ( platform_device_unregister  )
EXPORT_SYMBOL_GPL ( platform_device_register_full  )
EXPORT_SYMBOL_GPL ( platform_driver_register  )
EXPORT_SYMBOL_GPL ( platform_driver_unregister  )
EXPORT_SYMBOL_GPL ( platform_driver_probe  )
EXPORT_SYMBOL_GPL ( platform_create_bundle  )
EXPORT_SYMBOL_GPL ( platform_bus_type  )
EXPORT_SYMBOL_GPL ( dma_get_required_mask  )
int platform_add_devices ( struct platform_device **  devs,
int  num 
)

platform_add_devices - add a numbers of platform devices : array of platform devices to add : number of platform devices in array

Definition at line 143 of file platform.c.

int __init platform_bus_init ( void  )

Definition at line 880 of file platform.c.

struct platform_device* __init_or_module platform_create_bundle ( struct platform_driver driver,
int(*)(struct platform_device *)  probe,
struct resource res,
unsigned int  n_res,
const void data,
size_t  size 
)
read

platform_create_bundle - register driver and create corresponding device : platform driver structure : the driver probe routine, probably from an __init section : set of resources that needs to be allocated for the device : number of resources : platform specific data for this platform device : size of platform specific data

Use this in legacy-style modules that probe hardware directly and register a single platform device and corresponding platform driver.

Returns &struct platform_device pointer on success, or ERR_PTR() on error.

Definition at line 599 of file platform.c.

int platform_device_add ( struct platform_device pdev)

platform_device_add - add a platform device to device hierarchy : platform device we're adding

This is part 2 of platform_device_register(), though may be called separately iff pdev was allocated by platform_device_alloc().

Definition at line 279 of file platform.c.

int platform_device_add_data ( struct platform_device pdev,
const void data,
size_t  size 
)

platform_device_add_data - add platform-specific data to a platform device : platform device allocated by platform_device_alloc to add resources to : platform specific data for this platform device : size of platform specific data

Add a copy of platform specific data to the platform device's platform_data pointer. The memory associated with the platform data will be freed when the platform device is released.

Definition at line 255 of file platform.c.

int platform_device_add_resources ( struct platform_device pdev,
const struct resource res,
unsigned int  num 
)

platform_device_add_resources - add resources to a platform device : platform device allocated by platform_device_alloc to add resources to : set of resources that needs to be allocated for the device : number of resources

Add a copy of the resources to the platform device. The memory associated with the resources will be freed when the platform device is released.

Definition at line 227 of file platform.c.

struct platform_device* platform_device_alloc ( const char name,
int  id 
)
read

Definition at line 199 of file platform.c.

void platform_device_del ( struct platform_device pdev)

platform_device_del - remove a platform-level device : platform device we're removing

Note that this function will also release all memory- and port-based resources owned by the device (->resource). This function must only be externally called in error cases. All other usage is a bug.

Definition at line 370 of file platform.c.

void platform_device_put ( struct platform_device pdev)

platform_device_put - destroy a platform device : platform device to free

Free all memory associated with a platform device. This function must only be externally called in error cases. All other usage is a bug.

Definition at line 172 of file platform.c.

int platform_device_register ( struct platform_device pdev)

platform_device_register - add a platform-level device : platform device we're adding

Definition at line 397 of file platform.c.

struct platform_device* platform_device_register_full ( const struct platform_device_info pdevinfo)
read

platform_device_register_full - add a platform-level device with resources and platform-specific data

: data used to create device

Returns &struct platform_device pointer on success, or ERR_PTR() on error.

Definition at line 428 of file platform.c.

void platform_device_unregister ( struct platform_device pdev)

platform_device_unregister - unregister a platform-level device : platform device we're unregistering

Unregistration is done in 2 steps. First we release all resources and remove it from the subsystem, then we drop reference count by calling platform_device_put().

Definition at line 413 of file platform.c.

int __init_or_module platform_driver_probe ( struct platform_driver drv,
int(*)(struct platform_device *)  probe 
)

platform_driver_probe - register driver for non-hotpluggable device : platform driver structure : the driver probe routine, probably from an __init section

Use this instead of platform_driver_register() when you know the device is not hotpluggable and has already been registered, and you want to remove its run-once probe() infrastructure from memory after the driver has bound to the device.

One typical use for this would be with drivers for controllers integrated into system-on-chip processors, where the controller devices have been configured as part of board setup.

Returns zero if the driver registered and bound to a device, else returns a negative error code and with the driver not registered.

Definition at line 554 of file platform.c.

int platform_driver_register ( struct platform_driver drv)

platform_driver_register - register a driver for platform-level devices : platform driver structure

Definition at line 513 of file platform.c.

void platform_driver_unregister ( struct platform_driver drv)

platform_driver_unregister - unregister a driver for platform-level devices : platform driver structure

Definition at line 531 of file platform.c.

int platform_get_irq ( struct platform_device dev,
unsigned int  num 
)

platform_get_irq - get an IRQ for a device : platform device : IRQ number index

Definition at line 84 of file platform.c.

int platform_get_irq_byname ( struct platform_device dev,
const char name 
)

Definition at line 129 of file platform.c.

struct resource* platform_get_resource ( struct platform_device dev,
unsigned int  type,
unsigned int  num 
)
read

platform_get_resource - get a resource for a device : platform device : resource type : resource index

Definition at line 64 of file platform.c.

struct resource* platform_get_resource_byname ( struct platform_device dev,
unsigned int  type,
const char name 
)
read

Definition at line 105 of file platform.c.

Variable Documentation

struct device platform_bus
Initial value:
= {
.init_name = "platform",
}

Definition at line 34 of file platform.c.

struct bus_type platform_bus_type
Initial value:
= {
.name = "platform",
.dev_attrs = platform_dev_attrs,
.match = platform_match,
.uevent = platform_uevent,
.pm = &platform_dev_pm_ops,
}

Definition at line 871 of file platform.c.