Skip to content

Commit

Permalink
Merge branch 'fix/edma' into fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinod Koul committed Dec 10, 2015
2 parents e958e07 + ae0add7 commit bcb4b61
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 25 deletions.
10 changes: 4 additions & 6 deletions Documentation/devicetree/bindings/dma/ti-edma.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ Required properties:
Optional properties:
- ti,hwmods: Name of the hwmods associated to the eDMA CC
- ti,edma-memcpy-channels: List of channels allocated to be used for memcpy, iow
these channels will be SW triggered channels. The list must
contain 16 bits numbers, see example.
these channels will be SW triggered channels. See example.
- ti,edma-reserved-slot-ranges: PaRAM slot ranges which should not be used by
the driver, they are allocated to be used by for example the
DSP. See example.
Expand Down Expand Up @@ -56,10 +55,9 @@ edma: edma@49000000 {
ti,tptcs = <&edma_tptc0 7>, <&edma_tptc1 7>, <&edma_tptc2 0>;

/* Channel 20 and 21 is allocated for memcpy */
ti,edma-memcpy-channels = /bits/ 16 <20 21>;
/* The following PaRAM slots are reserved: 35-45 and 100-110 */
ti,edma-reserved-slot-ranges = /bits/ 16 <35 10>,
/bits/ 16 <100 10>;
ti,edma-memcpy-channels = <20 21>;
/* The following PaRAM slots are reserved: 35-44 and 100-109 */
ti,edma-reserved-slot-ranges = <35 10>, <100 10>;
};

edma_tptc0: tptc@49800000 {
Expand Down
53 changes: 35 additions & 18 deletions drivers/dma/edma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1752,16 +1752,14 @@ static enum dma_status edma_tx_status(struct dma_chan *chan,
return ret;
}

static bool edma_is_memcpy_channel(int ch_num, u16 *memcpy_channels)
static bool edma_is_memcpy_channel(int ch_num, s32 *memcpy_channels)
{
s16 *memcpy_ch = memcpy_channels;

if (!memcpy_channels)
return false;
while (*memcpy_ch != -1) {
if (*memcpy_ch == ch_num)
while (*memcpy_channels != -1) {
if (*memcpy_channels == ch_num)
return true;
memcpy_ch++;
memcpy_channels++;
}
return false;
}
Expand All @@ -1775,7 +1773,7 @@ static void edma_dma_init(struct edma_cc *ecc, bool legacy_mode)
{
struct dma_device *s_ddev = &ecc->dma_slave;
struct dma_device *m_ddev = NULL;
s16 *memcpy_channels = ecc->info->memcpy_channels;
s32 *memcpy_channels = ecc->info->memcpy_channels;
int i, j;

dma_cap_zero(s_ddev->cap_mask);
Expand Down Expand Up @@ -1996,16 +1994,16 @@ static struct edma_soc_info *edma_setup_info_from_dt(struct device *dev,
prop = of_find_property(dev->of_node, "ti,edma-memcpy-channels", &sz);
if (prop) {
const char pname[] = "ti,edma-memcpy-channels";
size_t nelm = sz / sizeof(s16);
s16 *memcpy_ch;
size_t nelm = sz / sizeof(s32);
s32 *memcpy_ch;

memcpy_ch = devm_kcalloc(dev, nelm + 1, sizeof(s16),
memcpy_ch = devm_kcalloc(dev, nelm + 1, sizeof(s32),
GFP_KERNEL);
if (!memcpy_ch)
return ERR_PTR(-ENOMEM);

ret = of_property_read_u16_array(dev->of_node, pname,
(u16 *)memcpy_ch, nelm);
ret = of_property_read_u32_array(dev->of_node, pname,
(u32 *)memcpy_ch, nelm);
if (ret)
return ERR_PTR(ret);

Expand All @@ -2017,31 +2015,50 @@ static struct edma_soc_info *edma_setup_info_from_dt(struct device *dev,
&sz);
if (prop) {
const char pname[] = "ti,edma-reserved-slot-ranges";
u32 (*tmp)[2];
s16 (*rsv_slots)[2];
size_t nelm = sz / sizeof(*rsv_slots);
size_t nelm = sz / sizeof(*tmp);
struct edma_rsv_info *rsv_info;
int i;

if (!nelm)
return info;

tmp = kcalloc(nelm, sizeof(*tmp), GFP_KERNEL);
if (!tmp)
return ERR_PTR(-ENOMEM);

rsv_info = devm_kzalloc(dev, sizeof(*rsv_info), GFP_KERNEL);
if (!rsv_info)
if (!rsv_info) {
kfree(tmp);
return ERR_PTR(-ENOMEM);
}

rsv_slots = devm_kcalloc(dev, nelm + 1, sizeof(*rsv_slots),
GFP_KERNEL);
if (!rsv_slots)
if (!rsv_slots) {
kfree(tmp);
return ERR_PTR(-ENOMEM);
}

ret = of_property_read_u16_array(dev->of_node, pname,
(u16 *)rsv_slots, nelm * 2);
if (ret)
ret = of_property_read_u32_array(dev->of_node, pname,
(u32 *)tmp, nelm * 2);
if (ret) {
kfree(tmp);
return ERR_PTR(ret);
}

for (i = 0; i < nelm; i++) {
rsv_slots[i][0] = tmp[i][0];
rsv_slots[i][1] = tmp[i][1];
}
rsv_slots[nelm][0] = -1;
rsv_slots[nelm][1] = -1;

info->rsv = rsv_info;
info->rsv->rsv_slots = (const s16 (*)[2])rsv_slots;

kfree(tmp);
}

return info;
Expand Down
2 changes: 1 addition & 1 deletion include/linux/platform_data/edma.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct edma_soc_info {
struct edma_rsv_info *rsv;

/* List of channels allocated for memcpy, terminated with -1 */
s16 *memcpy_channels;
s32 *memcpy_channels;

s8 (*queue_priority_mapping)[2];
const s16 (*xbar_chans)[2];
Expand Down

0 comments on commit bcb4b61

Please sign in to comment.