qcacmn: Add new QDF API's to handle gpio requirements

Add new QDF APIs to handle gpio, irqf and timer related
handling in TSF feature.

Change-Id: Iff6f85c6debe351c5533906559400b4a51333d4d
CRs-Fixed: 3469020
This commit is contained in:
Roopavathi Lingampalli
2023-03-24 13:16:20 +05:30
committed by Madan Koyyalamudi
parent 3a522a80e1
commit 36d5ce6684
9 changed files with 385 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
@@ -76,6 +77,117 @@ __qal_vbus_release_iorsc(int devnum)
return QDF_STATUS_SUCCESS;
}
/**
* __qal_vbus_allocate_iorsc() - allocate io resource
* @pinnum: pin Number
* @label: name of pin
*
* This function will allocate io resource
*
* Return: QDF_STATUS_SUCCESS on success
*/
static inline QDF_STATUS
__qal_vbus_allocate_iorsc(unsigned int pinnum, const char *label)
{
int ret;
ret = gpio_request(pinnum, label);
return qdf_status_from_os_return(ret);
}
/**
* __qal_vbus_iorsc_dir_output() - set pin dirction to output
* @pin: pin Number
* @val: value
*
* This function set the gpio pin direction to output
*
* Return: 0 on success, error no on failure
*/
static inline QDF_STATUS
__qal_vbus_iorsc_dir_output(unsigned int pin, int val)
{
int ret;
ret = gpio_direction_output(pin, val);
return qdf_status_from_os_return(ret);
}
/**
* __qal_vbus_iorsc_set_value() - set pin direction
* @pin: pin Number
* @val: value
*
* This function set the gpio pin direction based on value
*
* Return: QDF_STATUS_SUCCESS on success
*/
static inline QDF_STATUS
__qal_vbus_iorsc_set_value(unsigned int pin, int val)
{
gpio_set_value(pin, val);
return QDF_STATUS_SUCCESS;
}
/**
* __qal_vbus_iorsc_toirq() - set irq number to gpio
* @pin: pin Number
*
* This function set the irq number to gpio pin
*
* Return: QDF_STATUS_SUCCESS on success
*/
static inline QDF_STATUS
__qal_vbus_iorsc_toirq(unsigned int pin)
{
int ret;
ret = gpio_to_irq(pin);
return qdf_status_from_os_return(ret);
}
/**
* __qal_vbus_request_irq() - set interrupt handler
* @irqnum: irq Number
* @handler: function handler to be called
* @flags: irq flags
* @dev_name: device name
* @ctx: pointer to device context
*
* This function set up the handling of the interrupt
*
* Return: QDF_STATUS_SUCCESS on success, Error code on failure
*/
static inline QDF_STATUS
__qal_vbus_request_irq(unsigned int irqnum,
irqreturn_t (*handler)(int irq, void *arg),
unsigned long flags, const char *dev_name, void *ctx)
{
int ret;
ret = request_irq(irqnum, handler, flags, dev_name, ctx);
return qdf_status_from_os_return(ret);
}
/**
* __qal_vbus_free_irq() - free irq
* @irqnum: irq Number
* @ctx: pointer to device context
*
* This function free the irq number set to gpio pin
*
* Return: QDF_STATUS_SUCCESS on success
*/
static inline QDF_STATUS
__qal_vbus_free_irq(unsigned int irqnum, void *ctx)
{
free_irq(irqnum, ctx);
return QDF_STATUS_SUCCESS;
}
/**
* __qal_vbus_enable_devclk() - enable device clock
* @clk: Device clock