-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bus: mhi: core: Add support for basic PM operations
This commit adds support for basic MHI PM operations such as mhi_async_power_up, mhi_sync_power_up, and mhi_power_down. These routines places the MHI bus into respective power domain states and calls the state_transition APIs when necessary. The MHI controller driver is expected to call these PM routines for MHI powerup and powerdown. This is based on the patch submitted by Sujeev Dias: https://lkml.org/lkml/2018/7/9/989 Signed-off-by: Sujeev Dias <sdias@codeaurora.org> Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org> [mani: splitted the pm patch and cleaned up for upstream] Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Reviewed-by: Jeffrey Hugo <jhugo@codeaurora.org> Tested-by: Jeffrey Hugo <jhugo@codeaurora.org> Link: https://lore.kernel.org/r/20200220095854.4804-8-manivannan.sadhasivam@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
- Loading branch information
Manivannan Sadhasivam
authored and
Greg Kroah-Hartman
committed
Mar 19, 2020
1 parent
a6e2e35
commit 3000f85
Showing
7 changed files
with
801 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
obj-$(CONFIG_MHI_BUS) := mhi.o | ||
|
||
mhi-y := init.o main.o pm.o | ||
mhi-y := init.o main.o pm.o boot.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. | ||
* | ||
*/ | ||
|
||
#include <linux/delay.h> | ||
#include <linux/device.h> | ||
#include <linux/dma-direction.h> | ||
#include <linux/dma-mapping.h> | ||
#include <linux/firmware.h> | ||
#include <linux/interrupt.h> | ||
#include <linux/list.h> | ||
#include <linux/mhi.h> | ||
#include <linux/module.h> | ||
#include <linux/random.h> | ||
#include <linux/slab.h> | ||
#include <linux/wait.h> | ||
#include "internal.h" | ||
|
||
void mhi_free_bhie_table(struct mhi_controller *mhi_cntrl, | ||
struct image_info *image_info) | ||
{ | ||
int i; | ||
struct mhi_buf *mhi_buf = image_info->mhi_buf; | ||
|
||
for (i = 0; i < image_info->entries; i++, mhi_buf++) | ||
mhi_free_coherent(mhi_cntrl, mhi_buf->len, mhi_buf->buf, | ||
mhi_buf->dma_addr); | ||
|
||
kfree(image_info->mhi_buf); | ||
kfree(image_info); | ||
} | ||
|
||
int mhi_alloc_bhie_table(struct mhi_controller *mhi_cntrl, | ||
struct image_info **image_info, | ||
size_t alloc_size) | ||
{ | ||
size_t seg_size = mhi_cntrl->seg_len; | ||
int segments = DIV_ROUND_UP(alloc_size, seg_size) + 1; | ||
int i; | ||
struct image_info *img_info; | ||
struct mhi_buf *mhi_buf; | ||
|
||
img_info = kzalloc(sizeof(*img_info), GFP_KERNEL); | ||
if (!img_info) | ||
return -ENOMEM; | ||
|
||
/* Allocate memory for entries */ | ||
img_info->mhi_buf = kcalloc(segments, sizeof(*img_info->mhi_buf), | ||
GFP_KERNEL); | ||
if (!img_info->mhi_buf) | ||
goto error_alloc_mhi_buf; | ||
|
||
/* Allocate and populate vector table */ | ||
mhi_buf = img_info->mhi_buf; | ||
for (i = 0; i < segments; i++, mhi_buf++) { | ||
size_t vec_size = seg_size; | ||
|
||
/* Vector table is the last entry */ | ||
if (i == segments - 1) | ||
vec_size = sizeof(struct bhi_vec_entry) * i; | ||
|
||
mhi_buf->len = vec_size; | ||
mhi_buf->buf = mhi_alloc_coherent(mhi_cntrl, vec_size, | ||
&mhi_buf->dma_addr, | ||
GFP_KERNEL); | ||
if (!mhi_buf->buf) | ||
goto error_alloc_segment; | ||
} | ||
|
||
img_info->bhi_vec = img_info->mhi_buf[segments - 1].buf; | ||
img_info->entries = segments; | ||
*image_info = img_info; | ||
|
||
return 0; | ||
|
||
error_alloc_segment: | ||
for (--i, --mhi_buf; i >= 0; i--, mhi_buf--) | ||
mhi_free_coherent(mhi_cntrl, mhi_buf->len, mhi_buf->buf, | ||
mhi_buf->dma_addr); | ||
|
||
error_alloc_mhi_buf: | ||
kfree(img_info); | ||
|
||
return -ENOMEM; | ||
} |
Oops, something went wrong.