/*************************************************************************
* OK335xS pwm device register hacking
* 声明:
* 本文是对OK335xS pwm设备注册进行代码跟踪,其中有些部分是由于本人自己
* 添加的,但都是经过测试。
*
* 2015-8-25 晴 深圳 南山平山村 曾剑锋
************************************************************************/
MACHINE_START(AM335XEVM, "am335xevm")
/* Maintainer: Texas Instruments */
.atag_offset = 0x100,
.map_io = am335x_evm_map_io,
.init_early = am33xx_init_early,
.init_irq = ti81xx_init_irq,
.handle_irq = omap3_intc_handle_irq,
.timer = &omap3_am33xx_timer,
.init_machine = am335x_evm_init, ---------+
MACHINE_END |
|
MACHINE_START(AM335XIAEVM, "am335xiaevm") |
/* Maintainer: Texas Instruments */ |
.atag_offset = 0x100, |
.map_io = am335x_evm_map_io, |
.init_irq = ti81xx_init_irq, |
.init_early = am33xx_init_early, |
.timer = &omap3_am33xx_timer, |
.init_machine = am335x_evm_init, |
MACHINE_END |
|
|
static void __init am335x_evm_init(void) <--------+
{
......
setup_ok335xs(); ---------+
...... |
} |
|
static void setup_ok335xs(void) <--------+
{
pr_info("The board is a ok335xs.\n"); /* Starter Kit has Micro-SD slot which doesn't have Write Protect pin */
am335x_mmc[].gpio_wp = -EINVAL; _configure_device(EVM_SK, ok335xs_dev_cfg, PROFILE_NONE); --------+
|
am33xx_cpsw_init(AM33XX_CPSW_MODE_RGMII, NULL, NULL); |
/* Atheros Tx Clk delay Phy fixup */ |
phy_register_fixup_for_uid(AM335X_EVM_PHY_ID, AM335X_EVM_PHY_MASK, |
am33xx_evm_tx_clk_dly_phy_fixup); |
} |
|
static struct evm_dev_cfg ok335xs_dev_cfg[] = { <-------+
{mmc0_init, DEV_ON_BASEBOARD, PROFILE_ALL},//fixed
#if defined(CONFIG_ANDROID)
{mfd_tscadc_init, DEV_ON_BASEBOARD, PROFILE_ALL},
#endif
{rgmii1_init, DEV_ON_BASEBOARD, PROFILE_ALL},
{rgmii2_init, DEV_ON_BASEBOARD, PROFILE_ALL},
{lcdc_init, DEV_ON_BASEBOARD, PROFILE_ALL},//fixed
{i2c1_init, DEV_ON_BASEBOARD, PROFILE_ALL},
{buzzer_init, DEV_ON_BASEBOARD, PROFILE_ALL},//fixed --------+
{enable_ecap2, DEV_ON_BASEBOARD, PROFILE_ALL},//fixed |
{usb0_init, DEV_ON_BASEBOARD, PROFILE_ALL}, |
{usb1_init, DEV_ON_BASEBOARD, PROFILE_ALL}, |
{evm_nand_init,DEV_ON_BASEBOARD, PROFILE_ALL},//fixed |
{mcasp1_init, DEV_ON_BASEBOARD, PROFILE_NONE},//fixed |
{gpio_keys_init_forlinx_s, DEV_ON_BASEBOARD, PROFILE_ALL},//fixed |
{gpio_led_init_s, DEV_ON_BASEBOARD, PROFILE_ALL},//fixed |
{uart2_init_s, DEV_ON_BASEBOARD, PROFILE_ALL},//fixed |
{spi1_init_s, DEV_ON_BASEBOARD, PROFILE_ALL},//fixed |
{d_can_init, DEV_ON_BASEBOARD, PROFILE_ALL},//fixed |
{sgx_init, DEV_ON_BASEBOARD, PROFILE_ALL}, |
{NULL, , }, |
}; |
|
static void buzzer_init(int evm_id, int profile) <--------+
{
//setup_pin_mux(ecap0_pin_mux);
setup_pin_mux(ecap1_pin_mux); -----+ -------------------+
am33xx_register_ecap(, &pwm_pdata[]); ----*---------------------*+-+
} | || |
| || |
/* Module pin mux for eCAP1 */ | || |
static struct pinmux_config ecap1_pin_mux[] = { <----+ || |
{"spi0_cs1.ecap1_in_pwm1_out", -----+ || |
OMAP_MUX_MODE2 | AM33XX_PIN_OUTPUT}, | ---------------------+ || |
{NULL, }, | | || |
}; | | || |
| | || |
/* AM33XX pin mux super set */ | | || |
static struct omap_mux am33xx_muxmodes[] = { | --------------*+|| |
...... | |||| |
_AM33XX_MUXENTRY(SPI0_CS1, , V |||| |
//"spi0_cs1", "uart3_rxd", NULL, "mmc0_pow", |||| |
"spi0_cs1", "uart3_rxd", "ecap1_in_pwm1_out", "mmc0_pow", |||| |
NULL, "mmc0_sdcd", NULL, "gpio0_6"), |||| |
...... |||| |
} |||| |
|||| |
|||| |
/* 34xx mux mode options for each pin. See TRM for options */ |||| |
#define OMAP_MUX_MODE0 0 |||| |
#define OMAP_MUX_MODE1 1 |||| |
#define OMAP_MUX_MODE2 2 <-------------------------------------+||| |
#define OMAP_MUX_MODE3 3 ||| |
#define OMAP_MUX_MODE4 4 ||| |
#define OMAP_MUX_MODE5 5 ||| |
#define OMAP_MUX_MODE6 6 ||| |
#define OMAP_MUX_MODE7 7 ||| |
||| |
/* module pin mux structure */ ||| |
struct pinmux_config { <-------------------+|| |
const char *string_name; /* signal name format */ || |
int val; /* Options for the mux register value */ || |
}; || |
|| |
static void setup_pin_mux(struct pinmux_config *pin_mux) <---------------+| |
{ | |
int i; | |
| |
for (i = ; pin_mux->string_name != NULL; pin_mux++) | |
omap_mux_init_signal(pin_mux->string_name, pin_mux->val); --------+ | |
| | |
} | | |
| | |
int __init omap_mux_init_signal(const char *muxname, int val) <-------+ | |
{ | |
struct omap_mux_partition *partition = NULL; | |
struct omap_mux *mux = NULL; | |
u16 old_mode; | |
int mux_mode; | |
| |
mux_mode = omap_mux_get_by_name(muxname, &partition, &mux); --------+ | |
if (mux_mode < ) | | |
return mux_mode; | | |
| | |
old_mode = omap_mux_read(partition, mux->reg_offset); | | |
mux_mode |= val; | | |
pr_debug("%s: Setting signal %s 0x%04x -> 0x%04x\n", | | |
__func__, muxname, old_mode, mux_mode); | | |
omap_mux_write(partition, mux_mode, mux->reg_offset); | | |
| | |
return ; | | |
} | | |
| | |
int omap_mux_get_by_name(const char *muxname, <-------+ | |
struct omap_mux_partition **found_partition, | |
struct omap_mux **found_mux) | |
{ | |
struct omap_mux_partition *partition; | |
| |
list_for_each_entry(partition, &mux_partitions, node) { | |
struct omap_mux *mux = NULL; | |
int mux_mode = _omap_mux_get_by_name(partition, muxname, &mux); ---+ | |
if (mux_mode < ) | | |
continue; | | |
| | |
*found_partition = partition; | | |
*found_mux = mux; | | |
| | |
return mux_mode; +--------------------------------------------+ | |
} | | |
| | |
return -ENODEV; | | |
} | | |
V | |
static int __init _omap_mux_get_by_name(struct omap_mux_partition *partition, | |
const char *muxname, | |
struct omap_mux **found_mux) | |
{ | |
struct omap_mux *mux = NULL; | |
struct omap_mux_entry *e; | |
const char *mode_name; | |
int found = , found_mode = , mode0_len = ; | |
struct list_head *muxmodes = &partition->muxmodes; | |
| |
mode_name = strchr(muxname, '.'); | |
if (mode_name) { | |
mode0_len = strlen(muxname) - strlen(mode_name); | |
mode_name++; | |
} else { | |
mode_name = muxname; | |
} | |
| |
list_for_each_entry(e, muxmodes, node) { | |
char *m0_entry; | |
int i; | |
| |
mux = &e->mux; | |
m0_entry = mux->muxnames[]; | |
| |
/* First check for full name in mode0.muxmode format */ | |
if (mode0_len && strncmp(muxname, m0_entry, mode0_len)) | |
continue; | |
| |
/* Then check for muxmode only */ | |
for (i = ; i < OMAP_MUX_NR_MODES; i++) { | |
char *mode_cur = mux->muxnames[i]; | |
| |
if (!mode_cur) | |
continue; | |
| |
if (!strcmp(mode_name, mode_cur)) { | |
*found_mux = mux; | |
found++; | |
found_mode = i; | |
} | |
} | |
} | |
| |
if (found == ) { | |
return found_mode; | |
} | |
| |
if (found > ) { | |
pr_err("%s: Multiple signal paths (%i) for %s\n", __func__, | |
found, muxname); | |
return -EINVAL; | |
} | |
| |
pr_err("%s: Could not find signal %s\n", __func__, muxname); | |
| |
return -ENODEV; | |
} | |
| |
static struct pwmss_platform_data pwm_pdata[] = { <----------------+ |
{ |
.version = PWM_VERSION_1, |
}, |
{ |
.version = PWM_VERSION_1, |
}, |
{ |
.version = PWM_VERSION_1, |
}, |
}; |
|
#ifdef CONFIG_SOC_OMAPAM33XX |
#define PWM_STR_LEN 10 |
int __init am33xx_register_ecap(int id, struct pwmss_platform_data *pdata) <---+
{
struct platform_device *pdev;
struct omap_hwmod *oh;
char *oh_name = "ecap";
char dev_name[PWM_STR_LEN]; sprintf(dev_name, "ecap.%d", id); // for driver to match device name oh = omap_hwmod_lookup(dev_name);
if (!oh) {
pr_err("Could not look up %s hwmod\n", dev_name);
return -ENODEV;
} pdev = omap_device_build(oh_name, id, oh, pdata,
sizeof(*pdata), NULL, , ); if (IS_ERR(pdev)) {
WARN(, "Can't build omap_device for %s:%s.\n",
dev_name, oh->name);
return PTR_ERR(pdev);
}
return ;
}

OK335xS pwm device register hacking的更多相关文章

  1. OK335xS CAN device register and deiver match hacking

    /************************************************************************* * OK335xS CAN device regi ...

  2. OK335xS GPMC nand device register hacking

    /********************************************************************************* * OK335xS GPMC na ...

  3. OK335xS I2C device registe hacking

    /*************************************************************************** * OK335xS I2C device re ...

  4. I.MX6 Ar8031 device register hacking

    /***************************************************************************** * I.MX6 Ar8031 device ...

  5. OK335xS UART device registe hacking

    /************************************************************************* * OK335xS UART device reg ...

  6. OK335xS pwm buzzer Linux driver hacking

    /**************************************************************************** * OK335xS pwm buzzer L ...

  7. I.MX6 PWM buzzer driver hacking with Demo test

    /***************************************************************************** * I.MX6 PWM buzzer dr ...

  8. OK335xS davinci mdio driver hacking

    /******************************************************************************* * OK335xS davinci m ...

  9. I.MX6 Power off register hacking

    /*********************************************************************** * I.MX6 Power off register ...

随机推荐

  1. MVC扩展Url.Action方法解决复杂对象参数问题

    1:问题描述 @Url.Action("Index", "Home", new { Key = "Key", Val = new { Nam ...

  2. C++创建虚拟机调用JAVA类

    ZC: 简要摘抄: “ 1.      Object类出创建JVM. 使用Java类之前必须要创建JVM环境.JDK由java.exe来完成.本文有Object类的静态方法BeginJVM来创建,用E ...

  3. IdentityServer3零星笔记

    Scope 是什么?有哪几种类型?每种类型都怎么使用? StandardScopes.All是什么概念? 解释:在Scope的Claims属性里包含的所有声明(类型是ScopeClaim,它的name ...

  4. 关于angular5的惰性加载报错问题

    之前为了测试一个模块优化问题,于是用angular-cli快速搭建了个ng5的脚手架demo,在应用惰性加载功能的时候发现浏览器报错如下: ERROR Error: Uncaught (in prom ...

  5. 清空mailq 队列里面的邮件

    tmp_=`mailq | grep -E "root" | awk '{print $1}'` for i in $tmp_;do postsuper -d $i;done po ...

  6. Windows 环境下安装 Oracle JDK

    本页面中描述了如何在 Window 环境下安装 Oracle JDK. 我们使用的版本是 Window 10,我们需要安装的版本是 Oracle JDK 8u191. 检查当前版本 在进行新的 JDK ...

  7. in_array的效率

    in_array函数是个糟糕的选择.应该尽量用isset函数或array_key_exists函数来替代 .in_array函数的复杂度是O(n),而isset函数的复杂度是O(1) isset函数是 ...

  8. IDEA秒退或者一直让填写激活码问题

    IDEA秒退或者一直让填写激活码 1)复制  0.0.0.0 account.jetbrains.com 2)找到你本地的这个路径,我的电脑是windows,所以路径为: 3)点击hosts,添加刚刚 ...

  9. EchoService

    dubbo为consumer端的代理对象实现了EchoService接口. 使用示例: <dubbo:reference id="hello" interface=" ...

  10. ThreadPoolExecutor类

    首先分析内部类:ThreadPoolExecutor$Worker //Worker对线程和任务做了一个封装,同时它又实现了Runnable接口, //所以Worker类的线程跑的是自身的run方法 ...