Commit graph

537 commits

Author SHA1 Message Date
Dirk Brandewie
147d6585ae x86: arm: Modify IRQ_CONFIG macro to have same signature as ARC
In order to have drivers that are usable cross architecture the
signature for IRQ_CONFIG needs to be the same to avoid #ifdef hell in
the driver code based on architecture.

Update the macro and it usage for existing drivers

Change-Id: I22e142b21d4e984add231d1dbd97020e4823985f
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:31 -05:00
Dan Kalowsky
e4bb957a00 checkpatch: error - pointer_location
Change-Id: I9ce224cb75ba21caecffd6747833257f748b5ecf
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:31 -05:00
Dan Kalowsky
39063598db checkpatch: error - spacing
Change-Id: Ie6e1c43581dd4b0734625b3a4e59a4ca79619e99
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:31 -05:00
Dan Kalowsky
e899bb60ac i2c: changing file names to be consistent
Naming convention uses the _ not - in the file names.  In a recent
commit for I2C this for some reason changed.  Making the names now
more consistent with other files.

Change-Id: I1e363c0c09ae0c8b2ac3def3beeaaeafcc01eb74
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:31 -05:00
Allan Stephens
7b006066a4 init: Simplify symbol name generated by DECLARE_DEVICE_INIT_CONFIG()
Gets rid of the trailing initialization level character from the
name of the device variable generated by the macro, since it serves
no useful purpose. (The linker scripts place the various initialization
sections in ascending order based on the name of the section, so there
is no need to embed the initialization level in the variable name itself.)

Change-Id: I56bb79a513b8f77fb1f3fbaccec14454c2520772
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-02-05 20:24:29 -05:00
Javier B Perez Hernandez
f7fffae8aa Change BSD-3 licenses to Apache 2
Change all the Intel and Wind River code license from BSD-3 to Apache 2.

Change-Id: Id8be2c1c161a06ea8a0b9f38e17660e11dbb384b
Signed-off-by: Javier B Perez Hernandez <javier.b.perez.hernandez@linux.intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:24:29 -05:00
Daniel Leung
1c96cdeb52 i2c: simplify API and driver_api with generic transfer function
With the introduction of generic transfer function, it is no longer
needed to specify read or write functions explicitly in drivers.
All read/write functions can now thus call the generic transfer
function to achieve the same result.

With this change, the transfer function becomes mandatory, and
should always be available.

Change-Id: Ia6fb98e58b84330a56a5d44ed3df9db42c3a5e88
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:27 -05:00
Daniel Leung
01796ecf5c i2c: dw: implement generic transfer functions
() For interrupt driven transfer, the driver already has
   a generic transfer function, so this simply exposes it
   for public consumption.
() The polling write is extended to support generic
   transfer.

Change-Id: I657db8a6376282c723728b7a875813d389cf7d27
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:27 -05:00
Daniel Leung
76bfe7b3a1 i2c: dw: re-organize transfer related code
() Re-organize the steps involved in data transfer, according to
   the datasheet's flowchart.
() Extract the common code for transfer initialization and put
   it into its own function.
() i2c_write() and i2c_polling_write() are now using the common
   data sending function.

Change-Id: Ieb90253ee10ddceb3b5d05b258e7fc6253d18729
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:27 -05:00
Daniel Leung
6324168e88 i2c: dw: fix setting default configuration
Fix previous rebasing errors (before merging) where deleted code
was reintroduced back. This causes the default configuration
in Kconfig to be ignored.

Change-Id: I29b246b1459136521d764127bf02e6d8e5aff30c
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:22 -05:00
Daniel Leung
5992aa363b i2c: dw: ISR bails early if no interrupts
If using with shared IRQ, this function will be called by
the shared IRQ driver. So we need to check and bail out
early if the interrupt is not coming from the I2C controller.

Change-Id: I3c3ae3c22aa5cf312de5c22b35765749d6c5929d
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:22 -05:00
Tomasz Bursztyka
5d0bc718da i2c: Kconfig: Do not provide platform specific default settings
Such settings belong to Galileo and thus are set in Galileo Kconfig.

Change-Id: Ib9ec721fcc68e92521f8b7690c2640eeb82b2f4c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:24:22 -05:00
Tomasz Bursztyka
ddb35ccfa6 i2c: Support the generic API callback in designware's controller driver
Call the callback when relevant:
- When STOP_DET if received
- On error

Change-Id: Id60190c6ac5c0b15a0a6cd3fb30b9cc41f2333e8
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:24:21 -05:00
Daniel Leung
32121585da i2c: dw: add shared IRQ support
On some platforms (e.g. Galileo), the I2C controller is on PCI bus,
which shares IRQ with other devices (GPIO on Galileo). This patch
adds support for utilizing shared IRQ.

Change-Id: Id4e4714aed37c2893d0ffe9ed1e4edaabb338121
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:21 -05:00
Daniel Leung
bd86869cc5 i2c: dw: add polling write implementation
This implementation will wait to write, and wait for transfer
to complete before returning from the function. Currently has
a default timeout of 100ms to prevent being stuck in the loop
waiting for hardware to be ready.

Change-Id: I0340fc6fed100f1d31c0306c5b0ab09689364f63
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:21 -05:00
Dan Kalowsky
ccb9b8f338 i2c: dw: interrupt selection no longer controller specific
The interrupt selectionss are no longer specific to a particular
controller (e.g. I2C_DW_0), but apply to all controllers on
the platform.

[DL: Extracted these changes into their own patch, instead of
     being squashed with others. Also modified the Kconfig
     options to move them into proper position.]

Change-Id: Idc7ac9769e947447b868dccf772a95dbb5fc8021
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:21 -05:00
Daniel Leung
2104dcde39 i2c: dw: provide default configuration for controller at init
This adds the Kconfig option to specify default configuration
for the I2C controller during driver initialization.

During boot, the controller needs to be configured before
communication to slave devices can start. After boot,
an app can re-configure the controller if needed.

Change-Id: I7bf252f75a31943ae444e4d914f3a9a1a3f3d91f
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:21 -05:00
Dirk Brandewie
4365f02391 init: rename pure_late_init to pre_kernel_late_init
Change-Id: I9561315a892933370d60fcf36c10d38078d66233
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
2016-02-05 20:24:20 -05:00
Dirk Brandewie
58a534b929 init: add pure_core_init level
There are devices that need are part of the architecture core the need
to be initialized prior to devices that are integrated around a core
to make up a complete SOC. Namely the interrupt controller in the SOC
must be configured in order to allow the integrated IP blocks drivers
to initialize correctly.

Change-Id: I0a91e08f98516a7b7dd402ffc6494a071f1326b2
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
2016-02-05 20:24:20 -05:00
Dirk Brandewie
c48418f2bd init: remove pure_init macro
This macro is legacy from an early implementation of the init system
before the pure level was split into early and late phases remove it
now to avoid confusion going forward.

Change-Id: I6720874c840c9e14888fd6f411a8182e7420ca29
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
2016-02-05 20:24:19 -05:00
Dan Kalowsky
a853601c97 i2c: marking functions private
Following the naming convention established, private functions
should be prefixed with an _

Change-Id: Ib6006ba3a928da88b8b8c3324f7d4b833f736270
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:19 -05:00
Dan Kalowsky
daf7393808 i2c: naming functions to follow naming convention
Many of the i2c functions continue to exist in a format of
<IP>_<interface> and will now follow the <interface>_<IP>_
naming convention.

Change-Id: Ic7ec879105f5c06f0213f8d771b3811253c49658
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:19 -05:00
Dan Kalowsky
522cd73e04 i2c: fix interrupt clearing
Clearing an interrupt in DesignWare is done by reading the port
not by writing to it.  Original problem found by Dmitriy@WR.

Change-Id: I1de052632ec36e2d496c563e81307169e9dabcf4
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:19 -05:00
Anas Nashif
2dab2bd255 i2c: move irq stubs to driver
Change-Id: I4d6a40d3c5343b444678a4adcd78a8e3fe9ab515
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:18 -05:00
Daniel Leung
5e66dada51 i2c: dw: fix build error after file renames
The header file was renamed in previous commits, but the #include
referred to a non-existing file. This causes compilation error.
This uses the correct file.

Change-Id: Ibda7dbca82323d99dcff71cbee8f642f6cd611d6
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:18 -05:00
Anas Nashif
dcbf8d52b5 i2c: rename config variables I2C_DW0 -> I2C_DW_0
This makes variables readable and consistent with other drivers
we have.

Change-Id: I816f133279497eafd5d5614013c8d224d5909590
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:18 -05:00
Anas Nashif
722f42c6de i2c: move i2c kconfig entries from platform to driver
Change-Id: I1f93ccce09235fef65ad06a4a246315709203cba
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:18 -05:00
Anas Nashif
18a3fcff17 i2c: Update Kconfig for i2c drivers
use menuconfig and remove circular dependency

Change-Id: I4962c9f523c5d1487f49a153e1087a72301312d3
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:18 -05:00
Anas Nashif
f2241deaa4 rename i2c driver files using <type>-<driver name>
Follow the same order of <type>-<driver name>

Change-Id: Iac9f01f864c2ac76ee7aadf8cbdbb12835f39df4
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:18 -05:00
Anas Nashif
6d107887c6 i2c: rename DW_I2C -> I2C_DW
This driver naming is an exception which compared with all other drivers
we have. To keep things consistent the configuration options and variables
are renamed to <type>_<name>.

Change-Id: Ib95aa09630a507848f78d8f2c28706b545eed06d
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:18 -05:00
Daniel Leung
a5876981fe i2c: dw: fix compilation error
This was missing an include file, which caused the macro to not
be expanded correctly. Including init.h fixes the issue.

Change-Id: I6b190e0c75828d9b6eb42a84c213dfc174510740
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:18 -05:00
Dirk Brandewie
6865fb658f x86: i2c: Move system binding code to dw_i2c.c
The code fragment to bind the instances of the I2C driver is not
platform specific but is driver specific.

All the information required to bind a driver instance comes from
CONFIG_ variables.  Having the binding code with the driver code
avoids duplicating the code fragments in each platform where the
driver may be used.

Change-Id: I9ea132c9340437ccb292bb8f3fa3d3a2b2a794db
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
2016-02-05 20:24:17 -05:00
Tomasz Bursztyka
a566afbebd ia32_pci: Add support for the designware i2c controller
Only 1 port is available on Quark through the PCI bus.

Change-Id: Ie0e0173686947134d2553dd0fd0230ffa5a1d456
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:15:36 -05:00
Tomasz Bursztyka
17c8f74859 i2c: Adding support for PCI enabled dw i2c controller
Since such controller is found on Quark x1000 (Galileo, ...), it will
need to get configured and/or enabled through PCI.

Change-Id: I16d00364edcb17653eaaf073e87b4e5850de7299
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:15:36 -05:00
Dan Kalowsky
7958f22acd i2c: converting to sys-io functions
Using the OS provided sys-io functions for access to the registers
and lower level devices.

Change-Id: I1a88786189cbed0965f84146ffad9988a3b68a7b
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:15:36 -05:00
Dan Kalowsky
998cc8e3d4 i2c: import of Synopsis DesignWare I2C
Initial import of Synopsis DesignWare I2C driver functionality
for the Zephyr Project.  This import has been tested for host
master control.  While it does contain the code to work as a host
slave, this code has not yet been completely tested and validated.

Change-Id: I3df0214f6e3b6798f7dad4819d09c3ec5998e508
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:15:36 -05:00
Dan Kalowsky
1f63fb5de4 i2c: Adding makefile to build code
Adds the necessary changes to Kbuild and Makefiles to enable I2C
driver support to build.

Change-Id: I3113ccbbbbb4e06ef134ca73f509d2755a2abb59
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:15:36 -05:00