Linux API/linux2018. 4. 23. 13:46

잘은 모르겠지만.. PC에서 쓰이는 PWRBTN  같은 전원관련 스위치들은

PMIC를 통해 인터럽트를 발생시킨다고 하는데..

GPIO를 통한 인터럽트인지 I2C(혹은 SMBUS)를 통해 통보받은걸 인터럽트로 넘겨주는건진 모르겠다.


2.7.15 Power Control Signals

i.MX6 Qseven PMIC SOM supports two power control signals PWGIN and PWRBTN# on Qseven Edge connector.

PWGIN input from Qseven Edge connector is the active high signal which is used to enable the power of i.MX6

Qseven PMIC SOM. For more details on PWRGIN signal usage, refer section 3.1.2.

i.MX6 Qseven PMIC SOM supports PWRBTN# input from Qseven Edge connector which is the active low signal and

connected to i.MX6 CPU’s ONOFF pin. This pin can be used to On/Off the i.MX6 CPU by connecting push button in

the carrier board. When the board power is On, a button press between 750ms to 5s will send an interrupt to core to

request software to bring down the i.MX6 safely (if software supports). Otherwise, button press greater than 5s

results in a direct hardware power down which is applicable when software is unable to power Off the device. When

the i.MX6 CPU power supply is Off, a button press greater in duration than 750ms asserts an output signal to request

power from a power IC to power up the i.MX6 CPU. 

[링크 : http://www1.futureelectronics.com/doc/IWAVE%20SYSTEMS%20TECHNOLOGIES/G15MDataSheet.pdf]


 +static irqreturn_t pb_isr(int irq, void *dev_id)

+{

+ int ret;

+ int state;

+

+ ret = intel_soc_pmic_readb(DC_TI_SIRQ_REG);

+ if (ret < 0) {

+ pr_err("[%s] power button SIRQ REG read fail %d\n",

+ pb_input->name, ret);

+ return IRQ_NONE;

+ }

+

+ state = ret & SIRQ_PWRBTN_REL;

+

+ if (force_trigger && state) {

+ /* If we lost the press interrupt when short pressing

+ * power button to wake up board from S3, simulate one.

+ */

+ input_event(pb_input, EV_KEY, KEY_POWER, 1);

+ input_sync(pb_input);

+ input_event(pb_input, EV_KEY, KEY_POWER, 0);

+ input_sync(pb_input);

+ } else {

+ input_event(pb_input, EV_KEY, KEY_POWER, !state);

+ input_sync(pb_input);

+ pr_info("[%s] power button %s\n", pb_input->name,

+ state ? "released" : "pressed");

+ }

+

+ if (force_trigger)

+ force_trigger = 0;

+

+ return IRQ_HANDLED;

+}

+

+static int pb_probe(struct platform_device *pdev)

+{

+ int ret;

+

+ pwrbtn_irq = platform_get_irq(pdev, 0);

+ if (pwrbtn_irq < 0) {

+ dev_err(&pdev->dev,

+ "get irq fail: irq1:%d\n", pwrbtn_irq);

+ return -EINVAL;

+ }

+ pb_input = input_allocate_device();

+ if (!pb_input) {

+ dev_err(&pdev->dev, "failed to allocate input device\n");

+ return -ENOMEM;

+ }

+ pb_input->name = pdev->name;

+ pb_input->phys = "power-button/input0";

+ pb_input->id.bustype = BUS_HOST;

+ pb_input->dev.parent = &pdev->dev;

+ input_set_capability(pb_input, EV_KEY, KEY_POWER);

+ ret = input_register_device(pb_input);

+ if (ret) {

+ dev_err(&pdev->dev,

+ "failed to register input device:%d\n", ret);

+ input_free_device(pb_input);

+ return ret;

+ }

+

+ ret = request_threaded_irq(pwrbtn_irq, NULL, pb_isr,

+ IRQF_NO_SUSPEND, DRIVER_NAME, pdev);

+ if (ret) {

+ dev_err(&pdev->dev,

+ "[request irq fail0]irq:%d err:%d\n", pwrbtn_irq, ret);

+ input_unregister_device(pb_input);

+ return ret;

+ }

+

+ return 0;

+}

[링크 : https://github.com/.../uefi/cht-m1stable/patches/PWRBTN-add-driver-for-TI-PMIC.patch]


> +int intel_soc_pmic_set_pdata(const char *name, void *data, int len)

> +{

> + struct cell_dev_pdata *pdata;

> +

> + pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);

> + if (!pdata) {

> + pr_err("intel_pmic: can't set pdata!\n");

> + return -ENOMEM;

> + }

> +

> + pdata->name = name;

> + pdata->data = data;

> + pdata->len = len;

> +

> + list_add_tail(&pdata->list, &pdata_list);

> +

> + return 0;

> +}

> +EXPORT_SYMBOL(intel_soc_pmic_set_pdata); 

[링크 : https://patchwork.kernel.org/patch/4227571/]



+

근데... 정기적으로 읽긴 그런 애매한 녀석이고..

이걸 인터럽트로 어떻게 던지지?



[링크 : https://www.intel.com/.../datasheets/7-series-chipset-pch-datasheet.pdf]

'Linux API > linux' 카테고리의 다른 글

fopen64  (0) 2019.06.24
ubuntu iio rotate key 찾기 또 실패  (0) 2019.05.27
linux kernel governor 관련 코드  (0) 2018.04.17
linux shared memory 관련  (0) 2016.12.22
linux ipc  (0) 2016.12.20
Posted by 구차니