xref: /openbmc/linux/arch/arm/mach-omap2/omap_device.h (revision c1d1cd597fc77af3086470f8627d77f52f7f8b6c)
125c7d49eSTony Lindgren /*
225c7d49eSTony Lindgren  * omap_device headers
325c7d49eSTony Lindgren  *
425c7d49eSTony Lindgren  * Copyright (C) 2009 Nokia Corporation
525c7d49eSTony Lindgren  * Paul Walmsley
625c7d49eSTony Lindgren  *
725c7d49eSTony Lindgren  * Developed in collaboration with (alphabetical order): Benoit
825c7d49eSTony Lindgren  * Cousson, Kevin Hilman, Tony Lindgren, Rajendra Nayak, Vikram
925c7d49eSTony Lindgren  * Pandita, Sakari Poussa, Anand Sawant, Santosh Shilimkar, Richard
1025c7d49eSTony Lindgren  * Woodruff
1125c7d49eSTony Lindgren  *
1225c7d49eSTony Lindgren  * This program is free software; you can redistribute it and/or modify
1325c7d49eSTony Lindgren  * it under the terms of the GNU General Public License version 2 as
1425c7d49eSTony Lindgren  * published by the Free Software Foundation.
1525c7d49eSTony Lindgren  *
16*c1d1cd59SPaul Walmsley  * This type of functionality should be implemented as a proper
17*c1d1cd59SPaul Walmsley  * omap_bus/omap_device in Linux.
1825c7d49eSTony Lindgren  *
1925c7d49eSTony Lindgren  * omap_device differs from omap_hwmod in that it includes external
2025c7d49eSTony Lindgren  * (e.g., board- and system-level) integration details.  omap_hwmod
2125c7d49eSTony Lindgren  * stores hardware data that is invariant for a given OMAP chip.
2225c7d49eSTony Lindgren  */
2325c7d49eSTony Lindgren #ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_DEVICE_H
2425c7d49eSTony Lindgren #define __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_DEVICE_H
2525c7d49eSTony Lindgren 
2625c7d49eSTony Lindgren #include <linux/kernel.h>
2725c7d49eSTony Lindgren #include <linux/platform_device.h>
2825c7d49eSTony Lindgren 
292a296c8fSTony Lindgren #include "omap_hwmod.h"
3025c7d49eSTony Lindgren 
3125c7d49eSTony Lindgren extern struct dev_pm_domain omap_device_pm_domain;
3225c7d49eSTony Lindgren 
3325c7d49eSTony Lindgren /* omap_device._state values */
3425c7d49eSTony Lindgren #define OMAP_DEVICE_STATE_UNKNOWN	0
3525c7d49eSTony Lindgren #define OMAP_DEVICE_STATE_ENABLED	1
3625c7d49eSTony Lindgren #define OMAP_DEVICE_STATE_IDLE		2
3725c7d49eSTony Lindgren #define OMAP_DEVICE_STATE_SHUTDOWN	3
3825c7d49eSTony Lindgren 
3925c7d49eSTony Lindgren /* omap_device.flags values */
4025c7d49eSTony Lindgren #define OMAP_DEVICE_SUSPENDED		BIT(0)
4125c7d49eSTony Lindgren #define OMAP_DEVICE_NO_IDLE_ON_SUSPEND	BIT(1)
4225c7d49eSTony Lindgren 
4325c7d49eSTony Lindgren /**
4425c7d49eSTony Lindgren  * struct omap_device - omap_device wrapper for platform_devices
4525c7d49eSTony Lindgren  * @pdev: platform_device
4625c7d49eSTony Lindgren  * @hwmods: (one .. many per omap_device)
4725c7d49eSTony Lindgren  * @hwmods_cnt: ARRAY_SIZE() of @hwmods
4825c7d49eSTony Lindgren  * @_state: one of OMAP_DEVICE_STATE_* (see above)
4925c7d49eSTony Lindgren  * @flags: device flags
5025c7d49eSTony Lindgren  * @_driver_status: one of BUS_NOTIFY_*_DRIVER from <linux/device.h>
5125c7d49eSTony Lindgren  *
5225c7d49eSTony Lindgren  * Integrates omap_hwmod data into Linux platform_device.
5325c7d49eSTony Lindgren  *
5425c7d49eSTony Lindgren  * Field names beginning with underscores are for the internal use of
5525c7d49eSTony Lindgren  * the omap_device code.
5625c7d49eSTony Lindgren  *
5725c7d49eSTony Lindgren  */
5825c7d49eSTony Lindgren struct omap_device {
5925c7d49eSTony Lindgren 	struct platform_device		*pdev;
6025c7d49eSTony Lindgren 	struct omap_hwmod		**hwmods;
6125c7d49eSTony Lindgren 	unsigned long			_driver_status;
6225c7d49eSTony Lindgren 	u8				hwmods_cnt;
6325c7d49eSTony Lindgren 	u8				_state;
6425c7d49eSTony Lindgren 	u8                              flags;
6525c7d49eSTony Lindgren };
6625c7d49eSTony Lindgren 
6725c7d49eSTony Lindgren /* Device driver interface (call via platform_data fn ptrs) */
6825c7d49eSTony Lindgren 
6925c7d49eSTony Lindgren int omap_device_enable(struct platform_device *pdev);
7025c7d49eSTony Lindgren int omap_device_idle(struct platform_device *pdev);
7125c7d49eSTony Lindgren 
7225c7d49eSTony Lindgren /* Core code interface */
7325c7d49eSTony Lindgren 
7425c7d49eSTony Lindgren struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
7525c7d49eSTony Lindgren 					  struct omap_hwmod *oh, void *pdata,
76*c1d1cd59SPaul Walmsley 					  int pdata_len);
7725c7d49eSTony Lindgren 
7825c7d49eSTony Lindgren struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
7925c7d49eSTony Lindgren 					 struct omap_hwmod **oh, int oh_cnt,
80*c1d1cd59SPaul Walmsley 					 void *pdata, int pdata_len);
8125c7d49eSTony Lindgren 
8225c7d49eSTony Lindgren struct omap_device *omap_device_alloc(struct platform_device *pdev,
83*c1d1cd59SPaul Walmsley 				      struct omap_hwmod **ohs, int oh_cnt);
8425c7d49eSTony Lindgren void omap_device_delete(struct omap_device *od);
8525c7d49eSTony Lindgren int omap_device_register(struct platform_device *pdev);
8625c7d49eSTony Lindgren 
8725c7d49eSTony Lindgren struct device *omap_device_get_by_hwmod_name(const char *oh_name);
8825c7d49eSTony Lindgren 
8925c7d49eSTony Lindgren /* OMAP PM interface */
9025c7d49eSTony Lindgren int omap_device_get_context_loss_count(struct platform_device *pdev);
9125c7d49eSTony Lindgren 
9225c7d49eSTony Lindgren /* Other */
9325c7d49eSTony Lindgren 
9425c7d49eSTony Lindgren int omap_device_assert_hardreset(struct platform_device *pdev,
9525c7d49eSTony Lindgren 				 const char *name);
9625c7d49eSTony Lindgren int omap_device_deassert_hardreset(struct platform_device *pdev,
9725c7d49eSTony Lindgren 				 const char *name);
9825c7d49eSTony Lindgren 
9925c7d49eSTony Lindgren /* Get omap_device pointer from platform_device pointer */
10025c7d49eSTony Lindgren static inline struct omap_device *to_omap_device(struct platform_device *pdev)
10125c7d49eSTony Lindgren {
10225c7d49eSTony Lindgren 	return pdev ? pdev->archdata.od : NULL;
10325c7d49eSTony Lindgren }
10425c7d49eSTony Lindgren 
10525c7d49eSTony Lindgren static inline
10625c7d49eSTony Lindgren void omap_device_disable_idle_on_suspend(struct platform_device *pdev)
10725c7d49eSTony Lindgren {
10825c7d49eSTony Lindgren 	struct omap_device *od = to_omap_device(pdev);
10925c7d49eSTony Lindgren 
11025c7d49eSTony Lindgren 	od->flags |= OMAP_DEVICE_NO_IDLE_ON_SUSPEND;
11125c7d49eSTony Lindgren }
11225c7d49eSTony Lindgren 
11325c7d49eSTony Lindgren #endif
114