Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sun5i wip #79

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,512 changes: 2,512 additions & 0 deletions arch/arm/configs/a12_nuclear_defconfig

Large diffs are not rendered by default.

2,509 changes: 2,509 additions & 0 deletions arch/arm/configs/a13_nuclear_defconfig

Large diffs are not rendered by default.

87 changes: 71 additions & 16 deletions arch/arm/configs/sun5i_defconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Automatically generated make config: don't edit
# Linux/arm 3.0.36 Kernel Configuration
# Linux/arm 3.0.42 Kernel Configuration
#
CONFIG_ARM=y
CONFIG_CHIP_ID=1125
Expand Down Expand Up @@ -72,7 +72,8 @@ CONFIG_TINY_RCU=y
# CONFIG_PREEMPT_RCU is not set
# CONFIG_RCU_TRACE is not set
# CONFIG_TREE_RCU_TRACE is not set
# CONFIG_IKCONFIG is not set
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
CONFIG_LOG_BUF_SHIFT=19
CONFIG_CGROUPS=y
# CONFIG_CGROUP_DEBUG is not set
Expand Down Expand Up @@ -273,6 +274,7 @@ CONFIG_ARCH_SUN5I=y
#
# System MMU
#
CONFIG_SW_DEBUG_UART=1
# CONFIG_SUN5I_FPGA is not set

#
Expand Down Expand Up @@ -544,6 +546,8 @@ CONFIG_BLK_DEV_RAM_SIZE=4096
# CONFIG_CDROM_PKTCDVD is not set
# CONFIG_ATA_OVER_ETH is not set
CONFIG_SUN5I_NANDFLASH=y
CONFIG_SUNXI_NAND=y
# CONFIG_SUNXI_NAND_TEST is not set
# CONFIG_SENSORS_LIS3LV02D is not set
# CONFIG_MISC_DEVICES is not set
CONFIG_HAVE_IDE=y
Expand Down Expand Up @@ -661,7 +665,7 @@ CONFIG_BCM4330=m
# CONFIG_LIBERTAS is not set
# CONFIG_RT2X00 is not set
# CONFIG_MWIFIEX is not set
# CONFIG_RTL8192CU_SW is not set
CONFIG_RTL8192CU_SW=m

#
# Enable WiMAX (Networking options) to see the WiMAX drivers
Expand Down Expand Up @@ -730,8 +734,43 @@ CONFIG_KEYBOARD_SUN4IKEYPAD=m
CONFIG_KEYBOARD_SUN4I_KEYBOARD=m
CONFIG_KEYBOARD_HV2605_KEYBOARD=m
# CONFIG_IR_SUN5I is not set
# CONFIG_INPUT_MOUSE is not set
# CONFIG_INPUT_JOYSTICK is not set
CONFIG_INPUT_MOUSE=y
CONFIG_MOUSE_PS2=y
CONFIG_MOUSE_PS2_ALPS=y
CONFIG_MOUSE_PS2_LOGIPS2PP=y
CONFIG_MOUSE_PS2_SYNAPTICS=y
CONFIG_MOUSE_PS2_TRACKPOINT=y
# CONFIG_MOUSE_PS2_ELANTECH is not set
# CONFIG_MOUSE_PS2_SENTELIC is not set
# CONFIG_MOUSE_PS2_TOUCHKIT is not set
# CONFIG_MOUSE_SERIAL is not set
# CONFIG_MOUSE_APPLETOUCH is not set
# CONFIG_MOUSE_BCM5974 is not set
# CONFIG_MOUSE_VSXXXAA is not set
# CONFIG_MOUSE_SYNAPTICS_I2C is not set
CONFIG_INPUT_JOYSTICK=y
# CONFIG_JOYSTICK_ANALOG is not set
# CONFIG_JOYSTICK_A3D is not set
# CONFIG_JOYSTICK_ADI is not set
# CONFIG_JOYSTICK_COBRA is not set
# CONFIG_JOYSTICK_GF2K is not set
# CONFIG_JOYSTICK_GRIP is not set
# CONFIG_JOYSTICK_GRIP_MP is not set
# CONFIG_JOYSTICK_GUILLEMOT is not set
# CONFIG_JOYSTICK_INTERACT is not set
# CONFIG_JOYSTICK_SIDEWINDER is not set
# CONFIG_JOYSTICK_TMDC is not set
# CONFIG_JOYSTICK_IFORCE is not set
# CONFIG_JOYSTICK_WARRIOR is not set
# CONFIG_JOYSTICK_MAGELLAN is not set
# CONFIG_JOYSTICK_SPACEORB is not set
# CONFIG_JOYSTICK_SPACEBALL is not set
# CONFIG_JOYSTICK_STINGER is not set
# CONFIG_JOYSTICK_TWIDJOY is not set
# CONFIG_JOYSTICK_ZHENHUA is not set
# CONFIG_JOYSTICK_AS5011 is not set
# CONFIG_JOYSTICK_JOYDUMP is not set
# CONFIG_JOYSTICK_XPAD is not set
# CONFIG_INPUT_TABLET is not set
CONFIG_INPUT_TOUCHSCREEN=y
# CONFIG_TOUCHSCREEN_ADS7846 is not set
Expand Down Expand Up @@ -763,7 +802,9 @@ CONFIG_INPUT_TOUCHSCREEN=y
# CONFIG_TOUCHSCREEN_ST1232 is not set
# CONFIG_TOUCHSCREEN_TPS6507X is not set
CONFIG_TOUCHSCREEN_GT801=m
CONFIG_TOUCHSCREEN_GT818=m
CONFIG_TOUCHSCREEN_SUN4I_TS=m
CONFIG_TOUCHSCREEN_SW_TS=m
CONFIG_TOUCHSCREEN_FT5X_TS=m
CONFIG_TOUCHSCREEN_ZT8031=m
# CONFIG_TOUCHSCREEN_COASIA is not set
Expand Down Expand Up @@ -996,9 +1037,9 @@ CONFIG_FB=y
# CONFIG_FIRMWARE_EDID is not set
# CONFIG_FB_DDC is not set
# CONFIG_FB_BOOT_VESA_SUPPORT is not set
# CONFIG_FB_CFB_FILLRECT is not set
# CONFIG_FB_CFB_COPYAREA is not set
# CONFIG_FB_CFB_IMAGEBLIT is not set
CONFIG_FB_CFB_FILLRECT=y
CONFIG_FB_CFB_COPYAREA=y
CONFIG_FB_CFB_IMAGEBLIT=y
# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
# CONFIG_FB_SYS_FILLRECT is not set
# CONFIG_FB_SYS_COPYAREA is not set
Expand All @@ -1016,8 +1057,11 @@ CONFIG_FB=y
# Frame buffer hardware drivers
#
CONFIG_LYCHEE_FB_SUN5I=y
CONFIG_FB_SUNXI=y
CONFIG_LYCHEE_LCD_SUN5I=y
CONFIG_FB_SUNXI_LCD=y
CONFIG_LYCHEE_HDMI_SUN5I=y
CONFIG_FB_SUNXI_HDMI=y
# CONFIG_FB_ARMCLCD is not set
# CONFIG_FB_UVESA is not set
# CONFIG_FB_S1D13XXX is not set
Expand All @@ -1036,7 +1080,12 @@ CONFIG_LYCHEE_HDMI_SUN5I=y
# Console display driver support
#
CONFIG_DUMMY_CONSOLE=y
# CONFIG_FRAMEBUFFER_CONSOLE is not set
CONFIG_FRAMEBUFFER_CONSOLE=y
# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
# CONFIG_FONTS is not set
CONFIG_FONT_8x8=y
CONFIG_FONT_8x16=y
# CONFIG_LOGO is not set
CONFIG_SOUND=y
# CONFIG_SOUND_OSS_CORE is not set
Expand Down Expand Up @@ -1084,6 +1133,7 @@ CONFIG_SND_SOC_I2C_AND_SPI=y
CONFIG_HID_SUPPORT=y
CONFIG_HID=y
# CONFIG_HIDRAW is not set
# CONFIG_UHID is not set

#
# USB Input Devices
Expand Down Expand Up @@ -1312,7 +1362,7 @@ CONFIG_MMC_SUNXI_POWER_CONTROL=y
# SUNXI MMC/SD/SDIO Host Controller Drivers
#
CONFIG_MMC_SUNXI=y
CONFIG_MMC_SUNXI_DBG=y
# CONFIG_MMC_SUNXI_DBG is not set
# CONFIG_MEMSTICK is not set
# CONFIG_NEW_LEDS is not set
# CONFIG_NFC_DEVICES is not set
Expand Down Expand Up @@ -1472,7 +1522,8 @@ CONFIG_FS_MBCACHE=y
# CONFIG_JFS_FS is not set
# CONFIG_XFS_FS is not set
# CONFIG_GFS2_FS is not set
# CONFIG_FS_POSIX_ACL is not set
# CONFIG_OCFS2_FS is not set
CONFIG_FS_POSIX_ACL=y
CONFIG_FILE_LOCKING=y
CONFIG_FSNOTIFY=y
CONFIG_DNOTIFY=y
Expand All @@ -1482,12 +1533,14 @@ CONFIG_QUOTA=y
CONFIG_QUOTA_NETLINK_INTERFACE=y
# CONFIG_PRINT_QUOTA_WARNING is not set
# CONFIG_QUOTA_DEBUG is not set
CONFIG_QUOTA_TREE=y
# CONFIG_QFMT_V1 is not set
# CONFIG_QFMT_V2 is not set
CONFIG_QFMT_V2=y
CONFIG_QUOTACTL=y
# CONFIG_AUTOFS4_FS is not set
CONFIG_AUTOFS4_FS=y
CONFIG_FUSE_FS=y
CONFIG_CUSE=y
CONFIG_GENERIC_ACL=y

#
# Caches
Expand All @@ -1514,7 +1567,7 @@ CONFIG_FAT_FS=y
CONFIG_MSDOS_FS=y
CONFIG_VFAT_FS=y
CONFIG_FAT_DEFAULT_CODEPAGE=437
CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
CONFIG_FAT_DEFAULT_IOCHARSET="ascii"
CONFIG_NTFS_FS=y
# CONFIG_NTFS_DEBUG is not set
CONFIG_NTFS_RW=y
Expand All @@ -1526,9 +1579,11 @@ CONFIG_PROC_FS=y
CONFIG_PROC_SYSCTL=y
CONFIG_PROC_PAGE_MONITOR=y
CONFIG_SYSFS=y
# CONFIG_TMPFS is not set
CONFIG_TMPFS=y
CONFIG_TMPFS_POSIX_ACL=y
CONFIG_TMPFS_XATTR=y
# CONFIG_HUGETLB_PAGE is not set
# CONFIG_CONFIGFS_FS is not set
CONFIG_CONFIGFS_FS=y
# CONFIG_MISC_FILESYSTEMS is not set
CONFIG_NETWORK_FILESYSTEMS=y
CONFIG_NFS_FS=y
Expand Down
128 changes: 113 additions & 15 deletions drivers/i2c/busses/i2c-sunxi.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ static inline void aw_twi_disable_ack(void *base_addr)
unsigned int reg_val = readl(base_addr + TWI_CTL_REG);
reg_val &= ~TWI_CTL_ACK;
writel(reg_val, base_addr + TWI_CTL_REG);
return;
}

/* when sending ack or nack, it will send ack automatically */
Expand Down Expand Up @@ -467,6 +466,99 @@ static int aw_twi_stop(void *base_addr)
return AWXX_I2C_OK;
}

/* get SDA state */
static unsigned int aw_twi_get_sda(void *base_addr)
{
unsigned int status = 0;
status = TWI_LCR_SDA_STATE_MASK & readl(base_addr + TWI_LCR_REG);
status >>= 4;
return (status&0x1);
}

/* set SCL level(high/low), only when SCL enable */
static void aw_twi_set_scl(void *base_addr, unsigned int hi_lo)
{
unsigned int reg_val = readl(base_addr + TWI_LCR_REG);
reg_val &= ~TWI_LCR_SCL_CTL;
hi_lo &= 0x01;// mask
reg_val |= (hi_lo<<3);
writel(reg_val, base_addr + TWI_LCR_REG);
}

/* enable SDA or SCL */
static void aw_twi_enable_LCR(void *base_addr, unsigned int sda_scl)
{
unsigned int reg_val = readl(base_addr + TWI_LCR_REG);
sda_scl &= 0x01;// mask
if(sda_scl)
{
reg_val |= TWI_LCR_SCL_EN;//enable scl line control
}
else
{
reg_val |= TWI_LCR_SDA_EN;//enable sda line control
}
writel(reg_val, base_addr + TWI_LCR_REG);
}

/* disable SDA or SCL */
static void aw_twi_disable_LCR(void *base_addr, unsigned int sda_scl)
{
unsigned int reg_val = readl(base_addr + TWI_LCR_REG);
sda_scl &= 0x01;// mask
if(sda_scl)
{
reg_val &= ~TWI_LCR_SCL_EN;//disable scl line control
}
else
{
reg_val &= ~TWI_LCR_SDA_EN;//disable sda line control
}
writel(reg_val, base_addr + TWI_LCR_REG);
}

static int aw_twi_send_clk_9pulse(void *base_addr)
{
int twi_scl = 1;
int low = 0;
int high = 1;
int i = 0;

/* enable scl control */
aw_twi_enable_LCR(base_addr, twi_scl);

while(i < 10)
{
if( aw_twi_get_sda(base_addr)
&& aw_twi_get_sda(base_addr)
&& aw_twi_get_sda(base_addr) )
{
break;
}
/* twi_scl -> low */
aw_twi_set_scl(base_addr, low);
udelay(1000);

/* twi_scl -> high */
aw_twi_set_scl(base_addr, high);
udelay(1000);
i++;
}

if(aw_twi_get_sda(base_addr))
{
i2c_dbg("SDA is HIGH level now,okay. \n");
aw_twi_disable_LCR(base_addr, twi_scl);//disable
return AWXX_I2C_OK;
}
else
{
i2c_dbg("SDA is still Stuck Low Error,failed. \n");
aw_twi_disable_LCR(base_addr, twi_scl);//disable
return AWXX_I2C_FAIL;
}
}

/*
****************************************************************************************************
*
Expand Down Expand Up @@ -511,8 +603,6 @@ static void i2c_sunxi_addr_byte(struct sunxi_i2c *i2c)
}
//send 7bits+r/w or the first part of 10bits
aw_twi_put_byte(i2c->base_addr, &addr);

return;
}


Expand Down Expand Up @@ -761,8 +851,15 @@ static int i2c_sunxi_do_xfer(struct sunxi_i2c *i2c, struct i2c_msg *msgs, int nu
TWI_STAT_BUS_ERR != aw_twi_query_irq_status(i2c->base_addr) &&
TWI_STAT_ARBLOST_SLAR_ACK != aw_twi_query_irq_status(i2c->base_addr) ) {
i2c_dbg("bus is busy, status = %x\n", aw_twi_query_irq_status(i2c->base_addr));
ret = AWXX_I2C_RETRY;
goto out;
if( AWXX_I2C_OK == aw_twi_send_clk_9pulse(i2c->base_addr) )
{
break;
}
else
{
ret = AWXX_I2C_RETRY;
goto out;
}
}
//i2c_dbg("bus num = %d\n", i2c->adap.nr);
//i2c_dbg("bus name = %s\n", i2c->adap.name);
Expand Down Expand Up @@ -851,7 +948,6 @@ static int i2c_sunxi_clk_init(struct sunxi_i2c *i2c)
aw_twi_set_clock(apb_clk, i2c->bus_freq, i2c->base_addr);

return 0;

}

static int i2c_sunxi_clk_exit(struct sunxi_i2c *i2c)
Expand All @@ -865,7 +961,6 @@ static int i2c_sunxi_clk_exit(struct sunxi_i2c *i2c)
aw_twi_disable_sys_clk(i2c);

return 0;

}

static int i2c_sunxi_hw_init(struct sunxi_i2c *i2c)
Expand Down Expand Up @@ -893,7 +988,6 @@ static void i2c_sunxi_hw_exit(struct sunxi_i2c *i2c)
return;
}
aw_twi_release_gpio(i2c);

}

static int i2c_sunxi_probe(struct platform_device *dev)
Expand Down Expand Up @@ -1074,21 +1168,25 @@ static int __exit i2c_sunxi_remove(struct platform_device *dev)
static int i2c_sunxi_suspend(struct platform_device *pdev, pm_message_t state)
{
struct sunxi_i2c *i2c = platform_get_drvdata(pdev);
int i = 10;

i2c->suspend_flag = 1;

if(i2c->status != I2C_XFER_IDLE) {
i2c_dbg("[i2c-%d] suspend wihle xfer,dev addr = %x\n",
i2c->adap.nr, i2c->msg? i2c->msg->addr : 0xff);
}

/*
* twi0 is for power, it will be accessed by axp driver
* before twi resume, so, don't suspend twi0
*/
if(0 == i2c->bus_num) {
/* twi0 is for power, it will be accessed by axp driver
before twi resume, so, don't suspend twi0 */
i2c->suspend_flag = 0;
return 0;
}

while((i2c->status != I2C_XFER_IDLE) && (i-- > 0)) {
i2c_dbg("[i2c-%d] suspend wihle xfer,dev addr = 0x%x\n",
i2c->adap.nr, i2c->msg? i2c->msg->addr : 0xff);
msleep(100);
}

if(i2c_sunxi_clk_exit(i2c)) {
i2c_dbg("[i2c%d] suspend failed.. \n", i2c->bus_num);
i2c->suspend_flag = 0;
Expand Down
Loading