Lines Matching defs:hp
35 static int32_t PwmDumperCreate(struct HiPwm *hp)
41 PWM_DUMPER_NAME_PREFIX, hp->dev.num) < 0) {
52 hp->dumper = dumper;
53 hp->dumperName = name;
58 static void PwmDumperDump(struct HiPwm *hp)
62 {"PWM_CFG0", PLATFORM_DUMPER_REGISTERL, (void *)hp->base},
63 {"PWM_CFG1", PLATFORM_DUMPER_REGISTERL, (void *)(hp->base+ PWM_CFG1_SHIFT)},
64 {"PWM_CFG2", PLATFORM_DUMPER_REGISTERL, (void *)(hp->base + PWM_CFG2_SHIFT)},
65 {"PWM_CTRL", PLATFORM_DUMPER_REGISTERL, (void *)(hp->base + PWM_CTRL_SHIFT)},
66 {"PWM_STATE0", PLATFORM_DUMPER_REGISTERL, (void *)(hp->base + PWM_STATE0_SHIFT)},
67 {"PWM_STATE1", PLATFORM_DUMPER_REGISTERL, (void *)(hp->base + PWM_STATE1_SHIFT)},
68 {"PWM_STATE2", PLATFORM_DUMPER_REGISTERL, (void *)(hp->base + PWM_STATE2_SHIFT)},
70 if (hp->dumper == NULL) {
74 ret = PlatformDumperAddDatas(hp->dumper, datas, sizeof(datas) / sizeof(struct PlatformDumperData));
78 (void)PlatformDumperDump(hp->dumper);
79 (void)PlatformDumperClearDatas(hp->dumper);
82 static inline void PwmDumperDestroy(struct HiPwm *hp)
84 PlatformDumperDestroy(hp->dumper);
85 OsalMemFree(hp->dumperName);
90 struct HiPwm *hp = (struct HiPwm *)pwm;
91 if (hp == NULL || hp->reg == NULL || config == NULL) {
92 HDF_LOGE("%s: hp reg or config is null", __func__);
97 PwmDumperDump(hp);
102 PwmDumperDump(hp);
108 PwmDumperDump(hp);
111 HiPwmDisable(hp->reg);
112 if (pwm->cfg.polarity != config->polarity && hp->supportPolarity) {
113 HiPwmSetPolarity(hp->reg, config->polarity);
117 HiPwmSetPeriod(hp->reg, config->period);
121 HiPwmSetDuty(hp->reg, config->duty);
126 HiPwmAlwaysOutput(hp->reg);
129 HiPwmOutputNumberSquareWaves(hp->reg, config->number);
142 static void HiPwmRemove(struct HiPwm *hp)
144 if (hp->base != NULL) {
145 OsalIoUnmap((void *)hp->base);
147 OsalMemFree(hp);
150 static int32_t HiPwmProbe(struct HiPwm *hp, struct HdfDeviceObject *obj)
162 if (iface->GetUint32(obj->property, "num", &(hp->dev.num), 0) != HDF_SUCCESS) {
172 hp->base = OsalIoRemap(tmp, sizeof(struct HiPwmRegs));
173 if (hp->base == NULL) {
178 hp->reg = (struct HiPwmRegs *)hp->base;
179 hp->supportPolarity = true;
180 hp->dev.method = &g_pwmOps;
181 hp->dev.cfg.duty = PWM_DEFAULT_DUTY_CYCLE;
182 hp->dev.cfg.period = PWM_DEFAULT_PERIOD;
183 hp->dev.cfg.polarity = PWM_DEFAULT_POLARITY;
184 hp->dev.cfg.status = PWM_DISABLE_STATUS;
185 hp->dev.cfg.number = 0;
186 hp->dev.busy = false;
187 if (PwmDeviceAdd(obj, &(hp->dev)) != HDF_SUCCESS) {
188 OsalIoUnmap((void *)hp->base);
192 ret = PwmDumperCreate(hp);
195 OsalIoUnmap((void *)hp->base);
199 hp->dev.cfg.number, hp->dev.cfg.period, hp->dev.cfg.duty, hp->dev.cfg.polarity, hp->dev.cfg.status);
212 struct HiPwm *hp = NULL;
218 hp = (struct HiPwm *)OsalMemCalloc(sizeof(*hp));
219 if (hp == NULL) {
220 HDF_LOGE("%s: OsalMemCalloc hp error", __func__);
224 ret = HiPwmProbe(hp, obj);
227 OsalMemFree(hp);
229 PwmDumperDump(hp);
236 struct HiPwm *hp = NULL;
243 hp = (struct HiPwm *)obj->service;
244 if (hp == NULL) {
245 HDF_LOGE("%s: hp is null", __func__);
248 PwmDumperDestroy(hp);
249 PwmDeviceRemove(obj, &(hp->dev));
250 HiPwmRemove(hp);