Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Kontron PLD driver definitions
0004  *
0005  * Copyright (c) 2010-2012 Kontron Europe GmbH
0006  * Author: Michael Brunner <michael.brunner@kontron.com>
0007  */
0008 
0009 #ifndef _LINUX_MFD_KEMPLD_H_
0010 #define _LINUX_MFD_KEMPLD_H_
0011 
0012 /* kempld register definitions */
0013 #define KEMPLD_IOINDEX          0xa80
0014 #define KEMPLD_IODATA           0xa81
0015 #define KEMPLD_MUTEX_KEY        0x80
0016 #define KEMPLD_VERSION          0x00
0017 #define KEMPLD_VERSION_LSB      0x00
0018 #define KEMPLD_VERSION_MSB      0x01
0019 #define KEMPLD_VERSION_GET_MINOR(x) (x & 0x1f)
0020 #define KEMPLD_VERSION_GET_MAJOR(x) ((x >> 5) & 0x1f)
0021 #define KEMPLD_VERSION_GET_NUMBER(x)    ((x >> 10) & 0xf)
0022 #define KEMPLD_VERSION_GET_TYPE(x)  ((x >> 14) & 0x3)
0023 #define KEMPLD_BUILDNR          0x02
0024 #define KEMPLD_BUILDNR_LSB      0x02
0025 #define KEMPLD_BUILDNR_MSB      0x03
0026 #define KEMPLD_FEATURE          0x04
0027 #define KEMPLD_FEATURE_LSB      0x04
0028 #define KEMPLD_FEATURE_MSB      0x05
0029 #define KEMPLD_FEATURE_BIT_I2C      (1 << 0)
0030 #define KEMPLD_FEATURE_BIT_WATCHDOG (1 << 1)
0031 #define KEMPLD_FEATURE_BIT_GPIO     (1 << 2)
0032 #define KEMPLD_FEATURE_MASK_UART    (7 << 3)
0033 #define KEMPLD_FEATURE_BIT_NMI      (1 << 8)
0034 #define KEMPLD_FEATURE_BIT_SMI      (1 << 9)
0035 #define KEMPLD_FEATURE_BIT_SCI      (1 << 10)
0036 #define KEMPLD_SPEC         0x06
0037 #define KEMPLD_SPEC_GET_MINOR(x)    (x & 0x0f)
0038 #define KEMPLD_SPEC_GET_MAJOR(x)    ((x >> 4) & 0x0f)
0039 #define KEMPLD_IRQ_GPIO         0x35
0040 #define KEMPLD_IRQ_I2C          0x36
0041 #define KEMPLD_CFG          0x37
0042 #define KEMPLD_CFG_GPIO_I2C_MUX     (1 << 0)
0043 #define KEMPLD_CFG_BIOS_WP      (1 << 7)
0044 
0045 #define KEMPLD_CLK          33333333
0046 
0047 #define KEMPLD_TYPE_RELEASE     0x0
0048 #define KEMPLD_TYPE_DEBUG       0x1
0049 #define KEMPLD_TYPE_CUSTOM      0x2
0050 
0051 #define KEMPLD_VERSION_LEN      10
0052 
0053 /**
0054  * struct kempld_info - PLD device information structure
0055  * @major:  PLD major revision
0056  * @minor:  PLD minor revision
0057  * @buildnr:    PLD build number
0058  * @number: PLD board specific index
0059  * @type:   PLD type
0060  * @spec_major: PLD FW specification major revision
0061  * @spec_minor: PLD FW specification minor revision
0062  * @version:    PLD version string
0063  */
0064 struct kempld_info {
0065     unsigned int major;
0066     unsigned int minor;
0067     unsigned int buildnr;
0068     unsigned int number;
0069     unsigned int type;
0070     unsigned int spec_major;
0071     unsigned int spec_minor;
0072     char version[KEMPLD_VERSION_LEN];
0073 };
0074 
0075 /**
0076  * struct kempld_device_data - Internal representation of the PLD device
0077  * @io_base:        Pointer to the IO memory
0078  * @io_index:       Pointer to the IO index register
0079  * @io_data:        Pointer to the IO data register
0080  * @pld_clock:      PLD clock frequency
0081  * @feature_mask:   PLD feature mask
0082  * @dev:        Pointer to kernel device structure
0083  * @info:       KEMPLD info structure
0084  * @lock:       PLD mutex
0085  */
0086 struct kempld_device_data {
0087     void __iomem        *io_base;
0088     void __iomem        *io_index;
0089     void __iomem        *io_data;
0090     u32         pld_clock;
0091     u32         feature_mask;
0092     struct device       *dev;
0093     struct kempld_info  info;
0094     struct mutex        lock;
0095 };
0096 
0097 /**
0098  * struct kempld_platform_data - PLD hardware configuration structure
0099  * @pld_clock:          PLD clock frequency
0100  * @gpio_base           GPIO base pin number
0101  * @ioresource:         IO addresses of the PLD
0102  * @get_mutex:          PLD specific get_mutex callback
0103  * @release_mutex:      PLD specific release_mutex callback
0104  * @get_info:           PLD specific get_info callback
0105  * @register_cells:     PLD specific register_cells callback
0106  */
0107 struct kempld_platform_data {
0108     u32             pld_clock;
0109     int             gpio_base;
0110     struct resource         *ioresource;
0111     void (*get_hardware_mutex)  (struct kempld_device_data *);
0112     void (*release_hardware_mutex)  (struct kempld_device_data *);
0113     int (*get_info)         (struct kempld_device_data *);
0114     int (*register_cells)       (struct kempld_device_data *);
0115 };
0116 
0117 extern void kempld_get_mutex(struct kempld_device_data *pld);
0118 extern void kempld_release_mutex(struct kempld_device_data *pld);
0119 extern u8 kempld_read8(struct kempld_device_data *pld, u8 index);
0120 extern void kempld_write8(struct kempld_device_data *pld, u8 index, u8 data);
0121 extern u16 kempld_read16(struct kempld_device_data *pld, u8 index);
0122 extern void kempld_write16(struct kempld_device_data *pld, u8 index, u16 data);
0123 extern u32 kempld_read32(struct kempld_device_data *pld, u8 index);
0124 extern void kempld_write32(struct kempld_device_data *pld, u8 index, u32 data);
0125 
0126 #endif /* _LINUX_MFD_KEMPLD_H_ */