blob: 17ca1aec271033d7551c2ffd4cf22fd0c4724fb2 [file] [log] [blame]
Paul Walmsleyb04b65a2009-09-03 20:14:05 +03001/*
2 * omap_device headers
3 *
4 * Copyright (C) 2009 Nokia Corporation
5 * Paul Walmsley
6 *
7 * Developed in collaboration with (alphabetical order): Benoit
8 * Cousson, Kevin Hilman, Tony Lindgren, Rajendra Nayak, Vikram
9 * Pandita, Sakari Poussa, Anand Sawant, Santosh Shilimkar, Richard
10 * Woodruff
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 *
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -070016 * This type of functionality should be implemented as a proper
17 * omap_bus/omap_device in Linux.
Paul Walmsleyb04b65a2009-09-03 20:14:05 +030018 *
19 * omap_device differs from omap_hwmod in that it includes external
20 * (e.g., board- and system-level) integration details. omap_hwmod
21 * stores hardware data that is invariant for a given OMAP chip.
Paul Walmsleyb04b65a2009-09-03 20:14:05 +030022 */
23#ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_DEVICE_H
24#define __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_DEVICE_H
25
26#include <linux/kernel.h>
27#include <linux/platform_device.h>
28
Tony Lindgren2a296c82012-10-02 17:41:35 -070029#include "omap_hwmod.h"
Paul Walmsleyb04b65a2009-09-03 20:14:05 +030030
Kevin Hilman3ec2dec2012-02-15 11:47:45 -080031extern struct dev_pm_domain omap_device_pm_domain;
Kevin Hilman0d5e8252010-08-23 08:10:55 -070032
Paul Walmsleyb04b65a2009-09-03 20:14:05 +030033/* omap_device._state values */
34#define OMAP_DEVICE_STATE_UNKNOWN 0
35#define OMAP_DEVICE_STATE_ENABLED 1
36#define OMAP_DEVICE_STATE_IDLE 2
37#define OMAP_DEVICE_STATE_SHUTDOWN 3
38
Kevin Hilmanc03f0072011-07-12 22:48:19 +020039/* omap_device.flags values */
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -070040#define OMAP_DEVICE_SUSPENDED BIT(0)
Kevin Hilmanc03f0072011-07-12 22:48:19 +020041
Paul Walmsleyb04b65a2009-09-03 20:14:05 +030042/**
43 * struct omap_device - omap_device wrapper for platform_devices
44 * @pdev: platform_device
45 * @hwmods: (one .. many per omap_device)
46 * @hwmods_cnt: ARRAY_SIZE() of @hwmods
Paul Walmsleyb04b65a2009-09-03 20:14:05 +030047 * @_state: one of OMAP_DEVICE_STATE_* (see above)
48 * @flags: device flags
Kevin Hilmane7533452012-07-10 11:13:16 -070049 * @_driver_status: one of BUS_NOTIFY_*_DRIVER from <linux/device.h>
Paul Walmsleyb04b65a2009-09-03 20:14:05 +030050 *
51 * Integrates omap_hwmod data into Linux platform_device.
52 *
53 * Field names beginning with underscores are for the internal use of
54 * the omap_device code.
55 *
56 */
57struct omap_device {
Kevin Hilmand66b3fe2011-07-21 13:58:51 -070058 struct platform_device *pdev;
Paul Walmsleyb04b65a2009-09-03 20:14:05 +030059 struct omap_hwmod **hwmods;
Kevin Hilmane7533452012-07-10 11:13:16 -070060 unsigned long _driver_status;
Paul Walmsleyb04b65a2009-09-03 20:14:05 +030061 u8 hwmods_cnt;
62 u8 _state;
Kevin Hilmanc03f0072011-07-12 22:48:19 +020063 u8 flags;
Paul Walmsleyb04b65a2009-09-03 20:14:05 +030064};
65
66/* Device driver interface (call via platform_data fn ptrs) */
67
68int omap_device_enable(struct platform_device *pdev);
69int omap_device_idle(struct platform_device *pdev);
Paul Walmsleyb04b65a2009-09-03 20:14:05 +030070
71/* Core code interface */
72
Kevin Hilman3528c582011-07-21 13:48:45 -070073struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -070074 struct omap_hwmod *oh, void *pdata,
75 int pdata_len);
Paul Walmsleyb04b65a2009-09-03 20:14:05 +030076
Kevin Hilman3528c582011-07-21 13:48:45 -070077struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
Paul Walmsleyb04b65a2009-09-03 20:14:05 +030078 struct omap_hwmod **oh, int oh_cnt,
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -070079 void *pdata, int pdata_len);
Paul Walmsleyb04b65a2009-09-03 20:14:05 +030080
Ohad Ben-Cohen993e4fb2012-02-20 09:43:29 -080081struct omap_device *omap_device_alloc(struct platform_device *pdev,
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -070082 struct omap_hwmod **ohs, int oh_cnt);
Ohad Ben-Cohen993e4fb2012-02-20 09:43:29 -080083void omap_device_delete(struct omap_device *od);
84int omap_device_register(struct platform_device *pdev);
85
Nishanth Menon1f8a7d52011-07-27 15:02:32 -050086struct device *omap_device_get_by_hwmod_name(const char *oh_name);
Paul Walmsleydb2a60b2010-07-26 16:34:33 -060087
Paul Walmsleyb04b65a2009-09-03 20:14:05 +030088/* OMAP PM interface */
Tomi Valkeinenfc013872011-06-09 16:56:23 +030089int omap_device_get_context_loss_count(struct platform_device *pdev);
Paul Walmsleyb04b65a2009-09-03 20:14:05 +030090
91/* Other */
92
Omar Ramirez Luna8bb9fde2012-09-23 17:28:18 -060093int omap_device_assert_hardreset(struct platform_device *pdev,
94 const char *name);
95int omap_device_deassert_hardreset(struct platform_device *pdev,
96 const char *name);
Paul Walmsleyb04b65a2009-09-03 20:14:05 +030097
Kevin Hilmana470c422009-12-08 16:34:17 -070098/* Get omap_device pointer from platform_device pointer */
Kevin Hilmand66b3fe2011-07-21 13:58:51 -070099static inline struct omap_device *to_omap_device(struct platform_device *pdev)
100{
101 return pdev ? pdev->archdata.od : NULL;
102}
Kevin Hilmana470c422009-12-08 16:34:17 -0700103#endif