/*  *********************************************************************
 *  ASTRIS - Remote JTAG probe
 *
 *  SWD Bypass v2 Declaration
 *
 *  File: astris_swdbypass_v2.cpp
 *
 ***********************************************************************
 *
 *  Copyright (C) 2022 Apple Inc. All rights reserved.
 *
 *  This document is the property of Apple Inc.
 *  It is considered confidential and proprietary.
 *
 *  This document may not be reproduced or transmitted in any form,
 *  in whole or in part, without the express written permission of
 *  Apple Inc.
 ********************************************************************* */

#ifndef astris_swdbypass_v2_h
#define astris_swdbypass_v2_h

#include "astris_swdbypass.h"

class SWDBypassV2:
    public SWDBypass {

public:
    SWDBypassV2(AXchip_t *chip, AXap_t *ap);
    SWDBypassV2(AXconn_t *conn);
    ~SWDBypassV2();

protected:

    virtual uint32_t get_tgt_cfg(uint32_t tgt_sel) override;
    virtual int      set_bypass_channel_kis(int bypass_sel) override;

private:
    static const uint32_t
        S_DBG_SWD_GPIO_TGT_CFG_BREAKTOKENSEQ   = 16,
        S_DBG_SWD_GPIO_TGT_CFG_DRIVEPARKBIT_EN = 8,
        S_DBG_SWD_GPIO_TGT_CFG_TARGETSEL       = 0;
    static const uint32_t
        M_DBG_SWD_GPIO_TGT_CFG_BREAKTOKENSEQ   = _MM_MAKEMASK(16, S_DBG_SWD_GPIO_TGT_CFG_BREAKTOKENSEQ),
        M_DBG_SWD_GPIO_TGT_CFG_DRIVEPARKBIT_EN = _MM_MAKEMASK(1, S_DBG_SWD_GPIO_TGT_CFG_DRIVEPARKBIT_EN),
        M_DBG_SWD_GPIO_TGT_CFG_TARGETSEL       = _MM_MAKEMASK(5, S_DBG_SWD_GPIO_TGT_CFG_TARGETSEL);
};

#endif /* astris_swdbypass_v2_hpp */
