|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 |, o* r( p8 G5 s. H& \( L#include <linux/init.h>
0 r/ z% h# r$ h2 q* ?#include <linux/module.h>
* E+ M: C3 j& ^#include <linux/kernel.h>
p+ r" n# K- r% S* E#include <linux/types.h>
" \& o& z; t/ n; U+ W#include <linux/gpio.h> r+ a+ N' s# V( h9 n- Q
#include <linux/leds.h>+ K( Q# Z: e0 o- Z1 a9 }. I! {/ w
#include <linux/platform_device.h>
3 B' B0 F- D. u8 p) o+ c3 d& k' [
#include <asm/mach-types.h>; s6 r# V% c: J
#include <asm/mach/arch.h>, g3 `- C. F0 C, x1 O' e
#include <mach/da8xx.h>
/ B; }7 }: j: S5 x* ^% E f, r#include <mach/mux.h>" u0 R/ R5 q) K$ i( }
; o! K1 Q% H' U0 m/ v, }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ N, J. v; u, E: b& L) J# o#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 w1 n8 Z$ ?4 N) B; Y8 N3 T
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ q: W! q- j. f" a
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; }0 [4 q* ]$ C) ?% K" p2 {, l0 U7 L2 I# D' u+ d1 F+ q
/* assign the tl som board LED-GPIOs*/
; B# V/ ~ [) u, N" x/ }+ g* Hstatic const short da850_evm_tl_user_led_pins[] = {
[0 D& [& f4 c- {: {: E /* These pins are definition at <mach/mux.h> file */
! c J- A/ q% ~* @* }) C DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' g, ]2 u/ S( ^! W" `2 ?& p -1+ ]# p7 D# w, w8 e
};% F! I0 K4 A( G
) i! b+ ^' k( S7 l2 J! Mstatic struct gpio_led da850_evm_tl_leds[] = {
6 a% I8 c6 H( L; r {# g, Q/ I2 h. o- C! o! ?
.active_low = 0,
: Q# Z' X8 d4 T0 E2 J .gpio = DA850_USER_LED0,
" i0 t$ \: @" m& Q5 F .name = "user_led0",
! d0 p- b$ C( J; ~3 c+ v .default_trigger = "default-on",2 ~; Q9 [# \+ ~( e, Q& c; e
},
|# e0 n2 C# M* |: g5 d5 I {
' P: r2 c8 g# B# J3 B .active_low = 0,9 C, C, t+ r# d
.gpio = DA850_USER_LED1,
2 X" _* i+ [1 S7 ], R' T4 C .name = "user_led1",
7 Y# C& I! B( K* p: x' m .default_trigger = "default-on",
; |- P* D+ D/ t& g! s9 k8 o },
; t* B' A! p( f& h5 A6 H {
% }. A) d' x/ x% U# q/ j .active_low = 0,
2 B& Z4 R0 b8 @ U5 b' u" q$ O .gpio = DA850_USER_LED2,$ c; y3 j* h5 j: @6 y, L; d1 W
.name = "user_led2",
, T P+ h) K3 C; @4 c& ` .default_trigger = "default-on"," C* Q" E+ w) L5 Z( U6 y& u
},2 m- d, s" U o9 j0 B
{
* ^1 x& h2 {2 P+ b x* c2 U .active_low = 0,
8 d' W# ^! E3 h .gpio = DA850_USER_LED3,+ a* i3 p) V6 g$ b* l
.name = "user_led3",
! q8 F, B+ I% M% m7 ~ .default_trigger = "default-on",
9 K# m" u- o9 p/ Y3 F3 o0 } }, q: _3 l# g) B1 s
};
$ i; }" z: n( Q2 r4 X+ k+ P* S1 [& N/ X) |* p1 q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% G" z7 L6 X/ `' @. w2 X
.leds = da850_evm_tl_leds,
% Y' Q3 _9 I+ w/ s4 @- t1 D .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, g u1 J# d- C4 ^: ]) G: o};) I8 I, l# r: n$ A3 C* a
- t; \; p- V2 c5 q/ O& a# `
static void led_dev_release(struct device *dev)
; S) U) S& X4 t{
: G+ i7 N z& n0 I* x3 B% b9 b: G};
! O: [4 Y: s' t7 L, \( J- o- y7 T( L9 ^* A
static struct platform_device da850_evm_tl_leds_device = {3 D0 p. }, M' ]& D, J0 v. `! i# P
.name = "leds-gpio",
2 _0 Q' h& U, j+ G. R .id = 1,
% T" z) |* ]2 }+ v .dev = {
& o+ k2 h# v5 g- x& H .platform_data = &da850_evm_tl_leds_pdata, E8 O6 R3 q8 @# ]# t, H
.release = led_dev_release,- o$ \. j0 P6 w& Z# G4 Y4 Z
}0 j: [" e# O! d. ~5 E/ N/ p d
};
# ~3 J2 M) \! k3 g) z J( o/ E; ]8 v1 y2 o$ }8 l& V# E6 H
static int __init led_platform_init(void)
' k& N3 ~( v; e7 i; H1 q! ?{
, }% c6 K1 y/ c+ z' K int ret;
* K5 e' _3 {6 H! b5 I9 ?#if 0
/ Z7 |5 W" `% ]) |5 l ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 O0 b$ }! [$ N3 h
if (ret); T1 F$ l9 ~& J& _5 {
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& X- z* F2 _( l% ]5 B "%d\n", ret);
1 v- L5 P5 B$ Y( u#endif% c1 e, ~2 p6 ^" o& z
ret = platform_device_register(&da850_evm_tl_leds_device);% w, @3 i7 P$ x' k$ u
if (ret)
& N" G0 z8 h/ A) @* U0 p pr_warning("Could not register som GPIO expander LEDS");# [2 W6 l7 K0 A- _
else
& V9 \* ~1 U3 E4 F printk(KERN_INFO "LED register sucessful!\n");
& B/ Q( d, N- c9 j) t1 l5 m9 x" b. P
return ret;. v, b# \) |% q
}
: c( j) K* ]/ q6 ]8 Y: l" i C( {% z! B1 h: M) G+ c
static void __exit led_platform_exit(void)
. |, }4 e, c# G{4 O7 K+ @$ |( j! c2 {
platform_device_unregister(&da850_evm_tl_leds_device);
! v, ?2 \ f7 D2 L5 k/ w% |
& s8 e3 J7 C3 Y printk(KERN_INFO "LED unregister!\n");
/ L1 E5 X$ z* x, F B}
2 \: [/ z$ c4 M8 e$ J1 l& O% C+ Q1 P
module_init(led_platform_init);' v0 W& h$ c" d! o+ [; ]
module_exit(led_platform_exit);
( Q3 [* h7 r& f
! k. x Z1 Y* A/ V9 r; T# [0 SMODULE_DESCRIPTION("Led platform driver");$ s4 C2 K! _. H$ J: Q
MODULE_AUTHOR("Tronlong");6 R t6 s! b k7 c; r! I, |: x
MODULE_LICENSE("GPL");
) B4 @, B, ]1 G1 I
6 h4 G% R1 t3 s, N- j |
|