gsi.c (3c506add35c74acbe5a42d0a86963d11bef10d25) gsi.c (d2bb6e657f164e37fe6d170cac869904d9cc26bc)
1// SPDX-License-Identifier: GPL-2.0
2
3/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
4 * Copyright (C) 2018-2023 Linaro Ltd.
5 */
6
7#include <linux/types.h>
8#include <linux/bits.h>
9#include <linux/bitfield.h>
10#include <linux/mutex.h>
11#include <linux/completion.h>
12#include <linux/io.h>
13#include <linux/bug.h>
14#include <linux/interrupt.h>
15#include <linux/platform_device.h>
16#include <linux/netdevice.h>
17
18#include "gsi.h"
1// SPDX-License-Identifier: GPL-2.0
2
3/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
4 * Copyright (C) 2018-2023 Linaro Ltd.
5 */
6
7#include <linux/types.h>
8#include <linux/bits.h>
9#include <linux/bitfield.h>
10#include <linux/mutex.h>
11#include <linux/completion.h>
12#include <linux/io.h>
13#include <linux/bug.h>
14#include <linux/interrupt.h>
15#include <linux/platform_device.h>
16#include <linux/netdevice.h>
17
18#include "gsi.h"
19#include "reg.h"
19#include "gsi_reg.h"
20#include "gsi_private.h"
21#include "gsi_trans.h"
22#include "ipa_gsi.h"
23#include "ipa_data.h"
24#include "ipa_version.h"
25
26/**

--- 764 unchanged lines hidden (view full) ---

791/* Program a channel for use; there is no gsi_channel_deprogram() */
792static void gsi_channel_program(struct gsi_channel *channel, bool doorbell)
793{
794 size_t size = channel->tre_ring.count * GSI_RING_ELEMENT_SIZE;
795 u32 channel_id = gsi_channel_id(channel);
796 union gsi_channel_scratch scr = { };
797 struct gsi_channel_scratch_gpi *gpi;
798 struct gsi *gsi = channel->gsi;
20#include "gsi_reg.h"
21#include "gsi_private.h"
22#include "gsi_trans.h"
23#include "ipa_gsi.h"
24#include "ipa_data.h"
25#include "ipa_version.h"
26
27/**

--- 764 unchanged lines hidden (view full) ---

792/* Program a channel for use; there is no gsi_channel_deprogram() */
793static void gsi_channel_program(struct gsi_channel *channel, bool doorbell)
794{
795 size_t size = channel->tre_ring.count * GSI_RING_ELEMENT_SIZE;
796 u32 channel_id = gsi_channel_id(channel);
797 union gsi_channel_scratch scr = { };
798 struct gsi_channel_scratch_gpi *gpi;
799 struct gsi *gsi = channel->gsi;
800 const struct reg *reg;
799 u32 wrr_weight = 0;
800 u32 val;
801
802 /* We program all channels as GPI type/protocol */
803 val = ch_c_cntxt_0_type_encode(gsi->version, GSI_CHANNEL_TYPE_GPI);
804 if (channel->toward_ipa)
805 val |= CHTYPE_DIR_FMASK;
806 val |= u32_encode_bits(channel->evt_ring_id, ERINDEX_FMASK);

--- 7 unchanged lines hidden (view full) ---

814 * high-order 32 bits of the address of the channel ring,
815 * respectively.
816 */
817 val = lower_32_bits(channel->tre_ring.addr);
818 iowrite32(val, gsi->virt + GSI_CH_C_CNTXT_2_OFFSET(channel_id));
819 val = upper_32_bits(channel->tre_ring.addr);
820 iowrite32(val, gsi->virt + GSI_CH_C_CNTXT_3_OFFSET(channel_id));
821
801 u32 wrr_weight = 0;
802 u32 val;
803
804 /* We program all channels as GPI type/protocol */
805 val = ch_c_cntxt_0_type_encode(gsi->version, GSI_CHANNEL_TYPE_GPI);
806 if (channel->toward_ipa)
807 val |= CHTYPE_DIR_FMASK;
808 val |= u32_encode_bits(channel->evt_ring_id, ERINDEX_FMASK);

--- 7 unchanged lines hidden (view full) ---

816 * high-order 32 bits of the address of the channel ring,
817 * respectively.
818 */
819 val = lower_32_bits(channel->tre_ring.addr);
820 iowrite32(val, gsi->virt + GSI_CH_C_CNTXT_2_OFFSET(channel_id));
821 val = upper_32_bits(channel->tre_ring.addr);
822 iowrite32(val, gsi->virt + GSI_CH_C_CNTXT_3_OFFSET(channel_id));
823
824 reg = gsi_reg(gsi, CH_C_QOS);
825
822 /* Command channel gets low weighted round-robin priority */
823 if (channel->command)
824 wrr_weight = field_max(WRR_WEIGHT_FMASK);
825 val = u32_encode_bits(wrr_weight, WRR_WEIGHT_FMASK);
826
827 /* Max prefetch is 1 segment (do not set MAX_PREFETCH_FMASK) */
828
829 /* No need to use the doorbell engine starting at IPA v4.0 */

--- 10 unchanged lines hidden (view full) ---

840 else
841 val |= u32_encode_bits(GSI_ESCAPE_BUF_ONLY,
842 PREFETCH_MODE_FMASK);
843 }
844 /* All channels set DB_IN_BYTES */
845 if (gsi->version >= IPA_VERSION_4_9)
846 val |= DB_IN_BYTES;
847
826 /* Command channel gets low weighted round-robin priority */
827 if (channel->command)
828 wrr_weight = field_max(WRR_WEIGHT_FMASK);
829 val = u32_encode_bits(wrr_weight, WRR_WEIGHT_FMASK);
830
831 /* Max prefetch is 1 segment (do not set MAX_PREFETCH_FMASK) */
832
833 /* No need to use the doorbell engine starting at IPA v4.0 */

--- 10 unchanged lines hidden (view full) ---

844 else
845 val |= u32_encode_bits(GSI_ESCAPE_BUF_ONLY,
846 PREFETCH_MODE_FMASK);
847 }
848 /* All channels set DB_IN_BYTES */
849 if (gsi->version >= IPA_VERSION_4_9)
850 val |= DB_IN_BYTES;
851
848 iowrite32(val, gsi->virt + GSI_CH_C_QOS_OFFSET(channel_id));
852 iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id));
849
850 /* Now update the scratch registers for GPI protocol */
851 gpi = &scr.gpi;
852 gpi->max_outstanding_tre = channel->trans_tre_max *
853 GSI_RING_ELEMENT_SIZE;
854 gpi->outstanding_threshold = 2 * GSI_RING_ELEMENT_SIZE;
855
856 val = scr.data.word1;

--- 1457 unchanged lines hidden ---
853
854 /* Now update the scratch registers for GPI protocol */
855 gpi = &scr.gpi;
856 gpi->max_outstanding_tre = channel->trans_tre_max *
857 GSI_RING_ELEMENT_SIZE;
858 gpi->outstanding_threshold = 2 * GSI_RING_ELEMENT_SIZE;
859
860 val = scr.data.word1;

--- 1457 unchanged lines hidden ---