Armadilloフォーラム

armadillo 840で,ad7843コントローラを接続について

ma2013

2014年8月8日 16時04分

いつもお世話になっております。
MCSの馬と申します。

armadillo840ボードにad7843というコントローラを持つ4線式タッチスクリーンを接続したいですが,
調べたところ,ad7879-spi.cというドライバがありましたので,それが使えるかなと思っております。

具体的に,
カーネルでSPIインタフェースとad7879ドライバを有効にし,
タッチスクリーンをSPIインタフェースに接続したいと思っております。

上記ステップで簡単に行けるかどうかについて,
プロな方のアドバイスをちょっといただくと大変助かります,

ドライバーについて,まだ素人のレベルで,よければお願いいたします。

コメント

ma2013

2014年8月19日 9時24分

上記の操作は簡単に使えないでしょうか?
ご存知の方,ちょっとアドバスしてくれないでしょうか?

at_makoto.harada

2014年8月28日 11時18分

原田です。
ソースをさらっと見た所、ad7879ドライバは、以下のファイルで構成されているようです。

drivers/input/touchscreen/
Makefile
Kconfig
ad7879.c
ad7879.h
ad7879-spi.c

試していないのですが、大雑把な作業としては、

1. armadillo_840.c にad7879のデバイス情報を登録
2. カーネルコンフィグで以下のコンフィグを有効
config TOUCHSCREEN_AD7879
config TOUCHSCREEN_AD7879_SPI

といったところでしょうか?

#1のデバイス情報の登録は、以下に参考になるコードがあります。

blackfin/mach-bf527/boards/tll6527m.c
blackfin/mach-bf527/boards/ezbrd.c
blackfin/mach-bf527/boards/ezkit.c
blackfin/mach-bf538/boards/ezkit.c
blackfin/mach-bf537/boards/stamp.c

うまくいくといいですね。

ma2013

2014年9月1日 11時15分

原田 様へ

いつも大変お世話になっております。MCSのmaです。
詳しく教えてくださって,誠にお礼申し上げます。
実装できたら,またご返事いたします。

ma2013

2014年10月8日 8時37分

> 原田 様へ
>
> いつも大変お世話になっております。MCSのmaです。
> 詳しく教えてくださって,誠にお礼申し上げます。
> 実装できたら,またご返事いたします。

MCSのmaです。
いつもお世話になっております。

AD7843をarmadillo840のcon11に接続して動作したいですけど,
なかなか動作しませんでした。

下記に設定した状況をまとめましたが,
ご存知な方にご教授させていただきたいです。

● LCD拡張ボードのJP3をショットし,JP1,JP2はOPEN.
●  カーネルコンフィギュレーション:
CON7 extension board (Custom) ---> │ │
│ │ CON8 extension board (Custom) ---> │ │
│ │ *** Interface and Device select *** │ │
│ │ [ ] use CEU0 Lower [CLKs, SYNCs and D7-0] │ │
│ │ [ ] use CEU0 Upper [CLKs, SYNCs and D15-8] │ │
│ │ [ ] use CEU1 [CLKs, SYNCs and D7-0] │ │
│ │ [*] use FSIA as Slave │ │
│ │ Audio Codec (AUDIO: WM8978 codec) ---> │ │
│ │ [*] use GPIO-KEY │ │
│ │ [*] KEY: Power [KEY:PORT97] │ │
│ │ [*] KEY: Back [KEY:PORT98] │ │
│ │ [*] KEY: Menu [KEY:PORT99] │ │
│ │ [*] KEY: Home [KEY:PORT100] │ │
│ │ [ ] TOUCHSCREEN: ST1232 │ │
│ │ [ ] use I2C-GPIO3 [SCL:PORT194, SDA:PORT193] │ │
│ │ [*] use LCDC0 │ │
│ │ [*] have 24bit width [D23-18] │ │
│ │ [ ] have LCLK0 [PORT165] │ │
│ │ LCD (LCD: SCF0500) ---> │ │
│ │ Primary framebuffer (LCDC1) ---> │ │
│ │ [*] use LED-Driver TB62752 │ │
│ │ [*] use External LED │ │
│ │ [*] LED: EXT1 [LED:102] │ │
│ │ [*] LED: EXT2 [LED:59] │ │
│ │ [*] LED: EXT3 [LED:60] │ │
│ │ [*] LED: EXT4 [LED:10] │ │
│ │ [*] LED: EXT5 [LED:8] │ │
│ │ [*] LED: EXT6 [LED:7] │ │
│ │ [*] use MSIOF1 │ │
│ │ [*] SPI: User mode SPI device [CS:PORT73]

[ ] use SDHI1

--- SPI support │ │
│ │ [*] Debug support for SPI drivers │ │
│ │ *** SPI Master Controller Drivers *** │ │
│ │ < > Altera SPI Controller │ │
│ │ -*- Utilities for Bitbanging SPI masters │ │
│ │ < > GPIO-based bitbanging SPI Master │ │
│ │ < > OpenCores tiny SPI │ │
│ │ <*> SuperH MSIOF SPI controller │ │
│ │ < > SuperH HSPI controller │ │
│ │ < > Xilinx SPI controller common module │ │
│ │ < > DesignWare SPI controller core support │ │
│ │ *** SPI Protocol Masters *** │ │
│ │ <*> User mode SPI device driver support │ │
│ │ < > Infineon TLE62X0 (for power switching)

● board-armadillo840.cの修正部分

/* ad7843 */
static int ads7873_get_pendown_state(void)
{
    return gpio_get_value(GPIO_PORT172);
}
 
static struct ads7846_platform_data __initdata ad7873_pdata = {
    .model        = 7873,        /* AD7873 */
    .x_max        = 0xfff,
    .y_max        = 0xfff,
    .x_plate_ohms    = 620,
    .debounce_max    = 1,
    .debounce_rep    = 0,
    .debounce_tol    = (~0),
    .get_pendown_state = ads7873_get_pendown_state,
};
 
/* SPI.MSIOF */
static struct spi_board_info __maybe_unused msiof1_board_info[] __initdata = {
    /* this is inplementation dependent. */
    {
        .modalias = "ads7846",
        .max_speed_hz = 2000000,     /* max spi clock (SCK) speed in HZ */
        .bus_num = 1,
        .irq = irq_pin(4), /* IRQ4A */
        .chip_select = 0,    /* GPIO controlled SSEL */
        .platform_data = &ad7873_pdata,
        .mode = SPI_MODE_0,
    }
};
 
static struct gpio __maybe_unused msiof1_gpios[] = {
    { GPIO_FN_MSIOF1_TSCK_PORT72,    0,    "TSCK" },
    { GPIO_FN_MSIOF1_TXD_PORT74,    0,    "MISO" },
    { GPIO_FN_MSIOF1_RXD_PORT75,    0,    "MOSI" },
       { GPIO_PORT172,            0,    "TP_INT" },
};
 
static void a840_msiof_init(void)
{
    if (!IS_ENABLED(CONFIG_ARMADILLO840_MSIOF1))
        return;
 
    if (gpio_request_array_simple(msiof1_gpios, ARRAY_SIZE(msiof1_gpios))) {
        pr_err("Any MSIOF1 resources are already reserved.\n");
        return;
    }
 
    platform_device_register(&sh_msiof1_device);
 
    if (IS_ENABLED(CONFIG_ARMADILLO840_MSIOF1_DEVICE_SPIDEV_PORT73)) {
        gpio_request(GPIO_PORT73, NULL); /* CS */
        gpio_direction_output(GPIO_PORT73, 0);
 
        gpio_direction_input(GPIO_PORT172);
 
        spi_register_board_info(msiof1_board_info,
                    ARRAY_SIZE(msiof1_board_info));
    }
}

● 起動ログでの失敗情報

ads7846 spi1.0: unable to get regulator: -517
spi spi1.0: Driver ads7846 requests probe deferral

以上,どうぞ宜しくお願いいたします。

ma2013

2014年10月7日 13時12分

上記まとめ内容で,試しているドライバソースコードは

include/linux/spi/ads7846.h 
drivers/input/touchscreen/ads7846.c 

になり,
カーネルコンフィギュレーションは

  --- Touchscreens       
  <*>   ADS7846/TSC2046/AD7873 and AD(S)7843 based touchscreens

になります。
デバイスファイルはどうしても作成できない状態で,
とても困っております。
ご存知な方,アドバイスなどちょっとくださると大変助かります。

at_yashi

2014年10月8日 8時50分

> ads7846 spi1.0: unable to get regulator: -517

regulatorがとれてませんね。arch/arm/mach-shmobile/board-armadillo840.cにあるように、spi用に regulator の設定はしていますか? "vcc"という名前で登録する必要がありそうです。

ma2013

2014年10月8日 10時31分

> > ads7846 spi1.0: unable to get regulator: -517
>
> regulatorがとれてませんね。arch/arm/mach-shmobile/board-armadillo840.cにあるように、spi用に regulator の設定はしていますか? "vcc"という名前で登録する必要がありそうです。

MCSのmaです。
spiについて,regulatorの設定はしておりませんでした,
board-armadillo840.cを調べてみましたが,
regulatorの設定方法は分かりませんでした。

regulatorの設定をしないと,
SPIコントローラの電源は無効になっているという意味でしょうか?

申し訳ないですが,spiのregulatorの設定について,
もうちょっとコメントをいただいて宜しいでしょうか?

ma2013

2014年10月8日 15時51分

MCSのmaです。
ソースコードを調べてみましたが,
確かに,下記のところで失敗しております。

drivers/input/touchscreen/ads7846.c

static int __devinit ads7846_probe(struct spi_device *spi)
{
...
ts->reg = regulator_get(&spi->dev, "vcc");
if (IS_ERR(ts->reg)) {
err = PTR_ERR(ts->reg);
dev_err(&spi->dev, "unable to get regulator: %d\n", err);
goto err_free_gpio;
}

err = regulator_enable(ts->reg);
if (err) {
dev_err(&spi->dev, "unable to enable regulator: %d\n", err);
goto err_put_regulator;
}
...
}

ただ,
SPI のregulatorの設定方法はあまり分からなくて,
困っております。

ma2013

2014年10月10日 10時32分

MCSのmaです。

カーネルコンフィギュレーションで

--- Voltage and Current Regulator Support                                                         
  [ ]   Regulator debug support                                                                  
  [*]   Provide a dummy regulator if regulator lookups fail                 
  <*>   Fixed voltage regulator support   

と設定することで,
ad7843コントローラのドライバはインストールできましたので,
ご情報を下さったかたにお礼申し上げます。