|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' j9 f1 ^3 U5 V9 H9 D. _( e#include <linux/init.h>
: P& p5 N3 y+ y) p% z#include <linux/module.h>
) u/ j, A; P$ f ]#include <linux/kernel.h>8 ]' k0 c' k ` M- V$ ^' l* w Q
#include <linux/types.h>" k3 a$ U8 r4 ^& R- f$ w
#include <linux/gpio.h>
$ j% z# p5 b! i( R+ ^# z. o+ _( l#include <linux/leds.h>
3 E/ s, Y* [) V; e- S# {#include <linux/platform_device.h>6 J2 ^8 `( Q7 K) {: |7 \
6 n5 \, g. v2 ~9 B+ u: R#include <asm/mach-types.h>
( ~' l* M) q) W1 D( d#include <asm/mach/arch.h>4 D' O7 O! L1 p; |, L& i# p! D
#include <mach/da8xx.h>( N) [! `, M9 b) A9 E
#include <mach/mux.h>
3 I; z, v9 a$ `; g7 @+ L% `1 H/ w; A( o5 { o: g
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 M; l5 m, L5 X. Q: g7 J) r: S2 `#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 j, P0 m7 _) k! N, ?#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 A5 a% n7 ~, N& B1 Y6 E, d, r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- B/ d, S M' e) w: J
8 U! M& X. A/ S/ v: d6 B$ m1 ^
/* assign the tl som board LED-GPIOs*/9 |) ]1 r% z9 o* |+ P2 E8 V
static const short da850_evm_tl_user_led_pins[] = {$ g7 x, k/ b" m8 w
/* These pins are definition at <mach/mux.h> file */
V3 `! B" E; A; B DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 z6 t; s# ]4 E/ k4 W7 P& E -1
# N8 q: H7 [( z8 |: [};
) C; J* c8 i V8 E3 Z8 ~3 P; `& Y5 \ i1 ?
static struct gpio_led da850_evm_tl_leds[] = {
( D' W* Y9 K2 m {8 E1 s! x+ {" |
.active_low = 0,
6 f9 n$ X/ L' g% Q- ^8 r _+ K .gpio = DA850_USER_LED0,5 D# O, \* S; ?/ z
.name = "user_led0",
+ T9 G$ H" \4 Y4 g# h( R, [9 O .default_trigger = "default-on",
; G- y$ u- _' E" |7 D },8 y/ \2 c( M1 F$ E# `' y. z
{* d C% E/ w4 W2 o O
.active_low = 0,
6 J$ a& W4 ^ r9 v! d4 E/ q; j" k .gpio = DA850_USER_LED1,
/ ]- ]- f! U- Z) {9 K .name = "user_led1",4 M# G3 L% s n5 A% V y
.default_trigger = "default-on",
! k3 I6 ^6 V. Z, s+ ~# v },, ^" k" i! B. K6 h
{( V% S! f( C9 M: z- N8 W$ `
.active_low = 0,
& B: m4 _: B! Y6 V, n/ e: y, V; J2 r .gpio = DA850_USER_LED2,
9 k1 i% s$ n, w; K" h( }+ m0 B) k .name = "user_led2",/ j) J# C" i0 c8 ?2 B' h6 _
.default_trigger = "default-on",
9 L% M% {. A" s I },
" q4 j+ B/ `+ b h% p) ] ~ {
, Q/ y4 p8 x# E) W4 \ .active_low = 0,
% \/ D) o6 L4 D2 E .gpio = DA850_USER_LED3,
, p) j# i# P5 F) c" |/ h .name = "user_led3",
$ ?0 h) z9 J: V& a) T .default_trigger = "default-on",
9 S" V6 B& |' Q) f+ @ },) D0 t1 A7 \- h8 i& e
};4 Q7 t( d3 o$ R, |/ u/ |
s4 f6 g; P9 B3 ~: g
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" _( R" s$ ?* A9 `* c
.leds = da850_evm_tl_leds,
9 X( }: z# D* t& f* }0 k .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 n. u* ^6 O: X* b) m}; F h( Y9 Q1 z/ d5 y
) U# ~0 L9 u5 ? R9 a
static void led_dev_release(struct device *dev)7 ^1 I" i3 j+ }0 D' P
{
8 S6 U0 T3 R" k7 ~. o};
+ S7 \7 }7 h; [2 g* D4 Y. h& t# ?" u
static struct platform_device da850_evm_tl_leds_device = {# O9 V' z/ [+ r T2 \2 x
.name = "leds-gpio",
7 X4 F7 G5 w. l' q( D. h .id = 1,
" `) {4 E% w; O .dev = {" T6 A! ?2 q5 j9 b8 N6 S% @
.platform_data = &da850_evm_tl_leds_pdata,
& s5 r, @. G" u .release = led_dev_release,* g* x. k) ~* H7 W
}
8 T& e$ R2 s/ b {. T v};- D2 @ y5 ]6 z4 U. ?/ d+ P& P* I
9 `( A& y8 d0 d$ j8 y( T% l3 ?
static int __init led_platform_init(void)' Q( D2 G, ]0 l/ n: j6 w4 Z2 Y
{/ Q @" a, U0 N6 {5 M) W
int ret;
4 T) a3 Q) x4 \" s. \; P. S$ b#if 0
+ p& v) B+ x8 _ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ D" w+ w) L: Y) n- j if (ret)8 m' [7 [( J: S; A l, C8 N2 I
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* j" v- r1 [4 P( O% I# v: Z q( ]; O
"%d\n", ret);: B m! U! T; ^5 a
#endif
4 T2 o" D* ?9 p- y+ H1 K1 i2 m: D: m ret = platform_device_register(&da850_evm_tl_leds_device);
& }7 t o5 `9 ~, b) l1 W! O2 h2 c if (ret)/ z+ {+ c/ N! Y2 z
pr_warning("Could not register som GPIO expander LEDS");
( l( A2 a9 l. D/ u4 {% k else/ X, q$ @. J& N+ j( K+ J( ~( u. |
printk(KERN_INFO "LED register sucessful!\n");$ |, S2 m, {: b) M. { ]8 K+ K
$ b* m: I) P! g2 N7 W' c3 j return ret; \7 g) z7 y2 Y3 Q4 |3 |
}
6 F4 y: ?+ I- _ a. \# F# @
$ {$ s& F' S! Y M U+ Hstatic void __exit led_platform_exit(void)
y6 f( S( U& F5 x- N{
+ ?3 O) F9 X. e: j+ C platform_device_unregister(&da850_evm_tl_leds_device);
9 v: P( L7 s- t; |( x* R8 g4 O$ c1 e/ Z; E% l
printk(KERN_INFO "LED unregister!\n");
$ R. B8 W) C- N; H/ W}
7 F/ |/ z: d3 u- v2 U6 @* T Z1 G6 G8 b" a
module_init(led_platform_init);' @$ r/ [- C0 `/ G% Y
module_exit(led_platform_exit);: `' w+ Q: y9 I# f
; _! D6 j6 H: f' p, r. O5 [3 ]+ yMODULE_DESCRIPTION("Led platform driver");
& R0 d G" r! f& Z& J4 b9 mMODULE_AUTHOR("Tronlong");8 F3 ~' v8 p$ v$ M' Z6 x
MODULE_LICENSE("GPL");
7 j, N/ _* E7 a( Q$ o2 y9 C, f" P, E3 \
|
|